Oracle PL/SQL Tutorial/Sequences/Primary Key — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:45, 26 мая 2010
Populating a Primary Key Using a Sequence
SQL>
SQL>
SQL> CREATE TABLE myTable (
2 id INTEGER CONSTRAINT pk PRIMARY KEY,
3 status VARCHAR2(10)
4 );
Table created.
SQL> CREATE SEQUENCE my_seq NOCACHE;
Sequence created.
SQL>
SQL> INSERT INTO myTable (id, status) VALUES (my_seq.nextval, "PLACED");
1 row created.
SQL> INSERT INTO myTable (id, status) VALUES (my_seq.nextval, "PENDING");
1 row created.
SQL>
SQL> select * from myTable;
ID STATUS
---------- ----------
1 PLACED
2 PENDING
SQL>
SQL> drop table myTable;
Table dropped.
SQL> drop sequence my_seq;
Sequence dropped.