Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
740 B
0
Indexable
Never
Foreign key:
contraint is used for prevent action to destroy link beetween tables.

syntax:- create table tablename(column 1 datatype PK,colum2 datatype,-------column n datatype,
Foreign key(column name)
references tablename(columnname)

syntax: not suported in mysql
create table tablename(column 1 datatype PK,colum2 datatype,-------columnnamen datatype Foreign key(column name)
references tablename(columnname)

create table Customers
(customer_id int primary key,
first_name varchar(30), 
last_name varchar(30),	
age int,
country varchar(30));

create table Orders(
order_id int,
item varchar(30),	
amount int,	
customer_id int,
primary key (order_id),
foreign key (customer_id) references Customers(customer_id)
Leave a Comment