Index : 검색성능 빨라짐


PK : p Index

FK : S Index


CREATE  INDEX 이름  ON 테이블이름(컬럼이름);



















 





JOIN



이 순서대로 만들어야한다.

1. stu

2. prof

3. class

4. sugang



ex) 제일어려운 sugang테이블의 예


create table sugang(

cid int(11)

sid int(11) primary key(cid,uid),

foreign key(sid) references stu(id),

foreign key(cid) references class(cid)

)


















UNION을 사용 


--full outer join      (outer join)

SELECT * FROM stu 

LEFT JOIN prof

ON stu.pid = prof.pid

UNION

SELECT * FROM stu 

RIGHT JOIN prof

ON stu.pid = prof.pid;






+ Recent posts