Usually we can create One Primary key. Composite Primary key means multiple Column names in a table..
General Primary Key Syntax:-
Create table <Table_name>
(
Column_names <Data_type>
--------
--------
Primary Key (Column_name)
)
Composite Primary Key Syntax:-
Create table <Table_name>
(
Column_names <Data_type>
--------
--------
Primary Key (Column1,Column2)
)
We can Create Foreign Key on Composite Primary Key
Create table <Table_name>
(
Column_names <Data_type>,
--------,
--------,
Foreign key(TableB Columns) References TableA (Composite Primary Key Columns)
)
General Primary Key Syntax:-
Create table <Table_name>
(
Column_names <Data_type>
--------
--------
Primary Key (Column_name)
)
Composite Primary Key Syntax:-
Create table <Table_name>
(
Column_names <Data_type>
--------
--------
Primary Key (Column1,Column2)
)
We can Create Foreign Key on Composite Primary Key
Create table <Table_name>
(
Column_names <Data_type>,
--------,
--------,
Foreign key(TableB Columns) References TableA (Composite Primary Key Columns)
)
No comments:
Post a Comment