Recently , I am facing an issue with sequence in Oracle.
alter sequence seq_name increment by 100
will give me an error "Invalid sequence name"
However, if I changed it to
alter sequence "seq_name" increment by 100
It will work perfectly fine. Anyone is able to explain the rational behind this?
Thanks Sebastian
ps. I am using rails with oci8 to create my oracle tables.
Your sequence was created with case-sensitive name (using quatation marks), so you can refer to it only with strict name - in quotation marks. If you want to refer to it without such problems just create sequence not using quotation marks. Examples below (with table name):
SQL> create table "t1"(c int);
Table created.
SQL> select * from t1;
select * from t1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from "t1";
no rows selected
SQL> select * from "T1";
select * from "T1"
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> create table t2(c int);
Table created.
SQL> select * from t2;
no rows selected
SQL> select * from T2;
no rows selected
SQL> select * from "t2";
select * from "t2"
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from "T2"; -- name without quatation marks is uppercase by default
no rows selected
Sequence was created as lowercase. Like this:
CREATE SEQUENCE "seq_name" MINVALUE 1 MAXVALUE 999999999999999 INCREMENT BY 2 START WITH 1 CACHE 20 NOCYCLE NOKEEP NOSCALE GLOBAL ;
Example:
select * from user_sequences where sequence_name='SEQ_NAME'; --No rows selected
select * from user_sequences where sequence_name='seq_name'; -- 1 row
If you create with name : "SEQ_name".
select * from user_sequences where sequence_name='SEQ_name'; -- 1 row
Because, when you create an object (with object name enclosed with double quotes) it will store/create as it is. Without double quotes, it would be uppercase.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.