分类:
2008-10-27 14:20:36
SQL> CREATE TABLE employees
2 (
3 empno NUMBER(6),
4 NAME VARCHAR2(30),
5 dept_no NUMBER(2),
6 CONSTRAINT emp_pk PRIMARY KEY(empno)
7 USING INDEX
8 (CREATE UNIQUE INDEX emp_pk_idx ON employees(empno))
9 );
Table created.
SQL> select index_name,UNIQUENESS from user_indexes
2 where table_name=upper('employees');
INDEX_NAME UNIQUENES
------------------------------ ---------
EMP_PK_IDX UNIQUE
SQL> select CONSTRAINT_NAME,CONSTRAINT_TYPE,INDEX_NAME from user_constraints
2 where table_name=upper('employees');
CONSTRAINT_NAME C INDEX_NAME
------------------------------ - ------------------------------
EMP_PK P EMP_PK_IDX
SQL> CREATE TABLE employees
2 (
3 empno NUMBER(6) primary key,
4 NAME VARCHAR2(30),
5 dept_no NUMBER(2)
6 );
Table created.
SQL> ALTER TABLE employees DROP PRIMARY KEY KEEP INDEX;
Table altered.
SQL> select index_name,UNIQUENESS from user_indexes
2 where table_name=upper('employees');
INDEX_NAME UNIQUENES
------------------------------ ---------
SYS_C004180 UNIQUE