Creat Obj Examples
Creat Obj Examples
Table created.
Table altered.
Table altered.
/* Here is a primary key constraint. Notice, the object name. */
Table altered.
/* If you query the data dictionary, then you can see a list of constraints
FOR ALL TABLES. First, lets describe the data dictionary table with
constraint data in it to find the correct attribute names for the select
statement. */
CONSTRAINT_NAME
------------------------------
SYS_C00956
SYS_C00957
SYS_C00958
DEPT_DNO_PK
DEPT_MGRSSN_FK
SYS_C00964
SYS_C00965
PK_DEPT
SYS_C00959
SYS_C00960
DEPTLOC_DNODLOC_PK
CONSTRAINT_NAME
------------------------------
DEPTLOC_DNO_FK
PK_EMP
FK_DEPTNO
SYS_C00950
SYS_C00951
SYS_C00952
SYS_C00953
EMPLOYEE_SSN_PK
EMPLOYEE_SUPERSSN_FK
EMPLOYEE_DNO_FK
SYS_C00961
CONSTRAINT_NAME
------------------------------
SYS_C00962
SYS_C00963
PROJECT_PNO_PK
PROJECT_DNO_FK
SYS_C00954
SYS_C00955
28 rows selected.
/* If you query the data dictionary, you can see what tables
exist for you (Scott). */
TABLE_NAME
------------------------------
BONUS
DEPARTMENT
DEPENDENT
DEPT
DEPT_LOCATIONS
EMP
EMPLOYEE
INSTANCE
INSTANCE2
INSTANCE_RELATIONSHIP
PROJECT
/* Query the data dictionary and find the indexes that were built
automatically when the primary key constraints were created. *?
INDEX_NAME TABLE_OWNER
------------------------------ ------------------------------
DEPTLOC_DNODLOC_PK SCOTT
DEPT_DNO_PK SCOTT
EMPLOYEE_SSN_PK SCOTT
PK_DEPT SCOTT
PK_EMP SCOTT
PROJECT_PNO_PK SCOTT
6 rows selected.
1 row created.
1 row created.
/* Lets try to run them again since we altered the table with
the primary key constraint. Notice, the record cannot be inserted
again because the primary key data value would be duplicated. */