데이터베이스설계
[데이터베이스설계] 3-14 DB 변경연산 - insertion
젼젼39
2025. 2. 15. 22:51
insertion | insert into 테이블이름 values (‘넣을 값들’, ‘넣을 값들’, 넣을 숫자) ; //순서 맞춰야 함 insert into 테이블이름 (컬럼1, 컬럼2, 컬럼 3) values (‘넣을값’, ‘넣을값’, 넣을숫자) ; //순서 맞출필요X insert into 테이블이름 values (‘넣을값’, ‘넣을값’, null ) // null값 넣을 수 있음. 미정 또는 모를떄 한번에 여러 투플을 넣고 싶다면 insert문에 SFW 서브쿼리 쓰기. 그 result set의 투플들을 넣는다. SFW 문은 relation에 결과가 삽입되기 전에 다 완료된다. 서브쿼리를 먼저 실행해 투플 확보 후 그 투플들을 삽입하게 됨 Q) make each student in the Music department who has earned more than 144 credit hours an instructor in the Music department with a salary of $18,000 (144학점 이상 학생을 교수로, 급료줘) => insert into instructor select ID, name, dept_name, 18000 from student where dept_name = ‘Music’ and tot_cred > 144; |