Oracle PL/SQL/Constraints/Name for Primary Key — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:01, 26 мая 2010
Primary keys can explicitely be named
SQL> -- Primary keys can explicitely be named.
SQL> -- create table statement creates a table with a primary key whose name is pk_name.
SQL>
SQL> create table myTable (
2 a number,
3 b number,
4 c number,
5 constraint pk_name primary key (a, b)
6 );
Table created.
SQL>
SQL>
SQL> insert into myTable values (1,2,3);
1 row created.
SQL> insert into myTable values (1,4,3);
1 row created.
SQL> insert into myTable values (1,3,3);
1 row created.
SQL> insert into myTable values (1,5,3);
1 row created.
SQL> insert into myTable values (1,2,3);
insert into myTable values (1,2,3)
*
ERROR at line 1:
ORA-00001: unique constraint (SYS.PK_NAME) violated
SQL>
SQL> select * from myTable;
A B C
---------- ---------- ----------
1 2 3
1 4 3
1 3 3
1 5 3
SQL>
SQL> drop table myTable;
Table dropped.
SQL>
SQL>