SQL Basics - index(foreign key) > 그누5튜닝

그누5튜닝

SQL Basics - index(foreign key) 정보

SQL Basics - index(foreign key)

본문

Foreign Key를 세팅하기 전에는 아래 데이타가 들어감

insert into customer.Orders (OrderDate, CustomerID, ProductID) values (now(), 4, 2);

 

alter table cusomer.orders
add foreign key (CustomerID) references Customer(ID);

 

alter table customer.orders
add foreign key (ProductID) references Products(ID);

 

위와 같이 Foreign Key를 세팅해 두면 같은 insert문장이라도  에러가 남.

 

insert into customer.Orders (OrderDate, CustomerID, ProductID) values (now(), 4, 2);

 

800594872_1560973502.9564.png

 

https://youtu.be/9Pzj7Aj25lw?list=PLD20298E653A970F8&t=2693

공감
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로