본문 바로가기

분류 전체보기90

[데이터베이스설계] 3-16 updates with Scalar 서브쿼리 updateswithScalar서브쿼리 Q) recompute and update tot_creds value for all students=> update student S    set tot_cred = ( select sum(credits)          //scalar 서브쿼리가 산출하는 값을 여기 할당.                             from takes, course.                             where takes.course_id = course.course_id and  //학점을 얻기위해 정보대조                                          S.ID = takes.ID and                // 이 학생.. 2025. 2. 15.
[데이터베이스설계] 3-15 DB 변경연산 - update updateupdate 테이블명 set 변경식         (수정할 컬럼명 (비교연산자) 계산부분)                                   (수정할 컬럼명 (비교연산자) SFW 서브쿼리)Q) give a 5% salary raise to all instructors=> update instructor     set salary = salary * 1.05 Q) give a 5% salary raise to those instructors who earn less than 70000=> update instructor    set salary = salary * 1.05    where salary            //where 뒤에 조건문… Q) give a 5% salary .. 2025. 2. 15.
[데이터베이스설계] 3-14 DB 변경연산 - insertion insertioninsert into 테이블이름 values (‘넣을 값들’, ‘넣을 값들’, 넣을 숫자) ;             //순서 맞춰야 함 insert into 테이블이름 (컬럼1, 컬럼2, 컬럼 3) values (‘넣을값’, ‘넣을값’, 넣을숫자) ; //순서 맞출필요X insert into 테이블이름 values (‘넣을값’, ‘넣을값’, null )     // null값 넣을 수 있음. 미정 또는 모를떄 한번에 여러 투플을 넣고 싶다면 insert문에 SFW 서브쿼리 쓰기. 그 result set의 투플들을 넣는다. SFW 문은 relation에 결과가 삽입되기 전에 다 완료된다. 서브쿼리를 먼저 실행해 투플 확보 후 그 투플들을 삽입하게 됨 Q) make each student i.. 2025. 2. 15.