Create sequence.sqlFrom WikiJava
This tutorial talks about how to create sequences in oracle.
the articleThis is a simple tutorial on how to create a sequence in oracle sql. Sequences are used to auto increment a field's value every time a new row is inserted into a table. sequence.sqlREM CREATE the SEQUENCE AND give it a name CREATE SEQUENCE dept_deptid_seq REM SET the INCREMENT VALUE IN this CASE the VALUE IS incremented BY 10 every TIME a NEW ROW IS inserted. INCREMENT BY 10 REM SET the starting point FOR the SEQUENCE START WITH 310 REM SET the maximum VALUE FOR the SEQUENCE MAXVALUE 999 REM setting this attribute means that a NUMBER can NOT be reassigned even WHEN a ROW IS deleted NOCYCLE ; using_sequence.sqlREM instead OF a USER inserting the department_id the SEQUENCE IS called AND the next VALUE IS inserted INSERT INTO departments (department_id,department_name,manager_id,location_id) VALUES (dept_deptid_seq.NEXTVAL,'Systems',103,1000);
|
