Oracle: CREATE SEQUENCE
Oracle requires you to create a sequence as a separate object and then use the sequence object in the INSERT. The sequence has no role in the CREATE TABLE statement.
SQL> create sequence newseq; Sequence created. SQL> create table testseq 2 (num number not null, 3 name varchar2(10) not null); Table created.
The sequence you create can have any name, but you must use nextval with it in the INSERT to generate unique values.
SQL> insert into testseq 2 values ( newseq.nextval, 'Amir'); 1 row created.
Use the same code for two more inserts, changing the value in the name column so that you get rows for Marge and Tri. When you check the table, you'll find auto numbers in place.
SQL> select * 2 from testseq; NUM NAME --------- ---------- 1 Amir 2 Marge 3 Tri 3 rows selected.