COMING SOON 🚀

SQL Basics - index(foreign key)

· 6년 전 · 990

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

 

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

그누5튜닝

+
제목 글쓴이 날짜 조회
6년 전 조회 1,261
6년 전 조회 1,387
6년 전 조회 1,358
6년 전 조회 3,280
6년 전 조회 1,471
6년 전 조회 1,475
6년 전 조회 1,507
6년 전 조회 1,082
6년 전 조회 850
6년 전 조회 958
6년 전 조회 1,061
6년 전 조회 1,331
6년 전 조회 907
6년 전 조회 756
6년 전 조회 991
6년 전 조회 805
6년 전 조회 574
6년 전 조회 720
6년 전 조회 667
6년 전 조회 673
6년 전 조회 614
6년 전 조회 1,239
6년 전 조회 1,807
6년 전 조회 1,549
6년 전 조회 810
6년 전 조회 786
6년 전 조회 1,464
6년 전 조회 699
7년 전 조회 895
7년 전 조회 1,165