foreign key
SQL> alter table dept modify(deptno primary key);
Table altered.
SQL> alter table emp1 add foreign key(deptno) references dept(deptno);
Table altered.
SQL> alter table emp add constraint fk_dept foreign key (deptno) references dept;
Table altered.
SQL> create table emp1(empno number(10) primary key,ename varchar2(101),deptno number(10),
2 foreign key fk_dept references dept(deptno)
3 );
foreign key fk_dept references dept(deptno)
*
ERROR at line 2:
ORA-00906: missing left parenthesis
2 foreign key fk_dept references dept(deptno)
3 );
foreign key fk_dept references dept(deptno)
*
ERROR at line 2:
ORA-00906: missing left parenthesis
SQL> create table emp1(empno number(10) primary key,ename varchar2(101),deptno number(10),
2 foreign key (deptno) references dept(deptno)
3 );
2 foreign key (deptno) references dept(deptno)
3 );
Table created.
SQL> create table emp1(empno number(10),ename varchar2(101),deptno number(10),
2 constraint fk_dept1 foreign key (deptno) references dept(deptno)
3 );
2 constraint fk_dept1 foreign key (deptno) references dept(deptno)
3 );
Table created.
--drop table
SQL> drop table dept;
drop table dept
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys
SQL> drop table dept cascade constraint;
Table dropped.