programplug Logo

SQL Foreign Key

Foreign key In SQL

By using Foriegn key in a table you can maintain some relation between the two table in the database.
In other words you can also say that, a foreign key in one table allow a point primary key in an another table.

create table table_name
(coloumn1 datatype(size) constraints type),
coloumn2 datatype(size),
coloumn3 datatype(size),
coloumnn datatype(size));	  
create table employee
(E_ID number(5) unique,
E_NAME varchar2(20),
E_SALARY number(10));

Following error messages appear"unique constraints scott sys-avoided" When you avoid the Unique constraints.