SQL Basics - index(foreign key)

· 6년 전 · 962

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

|
댓글을 작성하시려면 로그인이 필요합니다.

그누5튜닝

+
제목 글쓴이 날짜 조회
6년 전 조회 1,206
6년 전 조회 1,347
6년 전 조회 1,312
6년 전 조회 3,234
6년 전 조회 1,426
6년 전 조회 1,431
6년 전 조회 1,446
6년 전 조회 1,043
6년 전 조회 821
6년 전 조회 934
6년 전 조회 1,035
6년 전 조회 1,300
6년 전 조회 852
6년 전 조회 718
6년 전 조회 963
6년 전 조회 771
6년 전 조회 552
6년 전 조회 693
6년 전 조회 639
6년 전 조회 640
6년 전 조회 588
6년 전 조회 1,217
6년 전 조회 1,776
6년 전 조회 1,515
6년 전 조회 775
6년 전 조회 761
6년 전 조회 1,445
6년 전 조회 682
7년 전 조회 874
7년 전 조회 1,147