본 실습은 Oracle9i introduction to Oracle9i SQL vol2의 '14장 sql 강습' 을 토대로 진행했습니다.
※ALTER
객체 수정을 위한 명령어
-테이블 수정
▶열 추가
ALTER TABLE table ADD (열 이름 타입 제약조건);
해당 테이블의 열 추가
▶열 변경
ALTER TABLE table MODIFY (열 이름 타입 제약조건);
해당 테이블의 열 수정
▶열 삭제
ALTER TABLE table DROP COLUMN 열 이름;
해당 테이블의 열 삭제
7.
a. TITLE 테이블에 PRICE 열을 추가하여 비디오 구입 가격을 기록하십시오. 열은 소수 둘째 자리까지 포함하여 총 8자리로 표시하십시오.
테이블 열 추가 스크립트
alter table title add (price number(8,2));
b. TITLE table 의 가격을 갱신하시오
update title set price = 25 where title = 'Willie and Christmas Too';
update title set price = 35 where title = 'Alien Again';
update title set price = 35 where title = 'The Glob';
update title set price = 35 where title = 'My Day Off';
update title set price = 30 where title = 'Miracles on Ice';
update title set price = 35 where title = 'Soda Gang';
update title set price = 29 where title = 'Interstellar Wars';
update title set price = 35 where title = 'Alien Again';
update title set price = 35 where title = 'The Glob';
update title set price = 35 where title = 'My Day Off';
update title set price = 30 where title = 'Miracles on Ice';
update title set price = 35 where title = 'Soda Gang';
update title set price = 29 where title = 'Interstellar Wars';
c. PRICE 열에 제약 조건을 적용하고, 제약조건을 확인하십시오.
테이블 행 수정 스크립트
alter table title modify (price number(8,2) constraint TITLE_PRICE_NN not null);
테이블 제약조건 조회 스크립
select * from all_constraints where table_name in ('MEMBER', 'RENTAL', 'RESERVATION','TITLE','TITLE_COPY');

댓글
댓글 쓰기