반응형
1. Oracle Table 수정/추가/삭제 등등
Oracle DB 및 다른 DB도 마찬가지로 운영하다 보면 Table에 대한 변경 작업을 하기 마련입니다. 오늘은 헷갈릴수도 있는
테이블 수정 명령을 확인해 보겠습니다.
1. Table에 컬럼 추가
alter table [TB_NAME] add (컬럼명 데이터타입(데이터크기));
ex) alter table scott.test_table add test_col1 varchar2(30);
혹은 여러 컬럼을 추가할때
ex) alter table scott.test_table add
(test_col1 varchar2(30),
test_col2 varchar2(1),
test_col3 date );
2. Table 컬럼 속성 변경 및 data 크리 resize
alter table [TB_NAME] modify (컬럼명 데이터타입(데이터크기));
ex) alter table scott.test_table modify test_col1 varchar2(35);
or
alter table scott.test_table modify test_col1 number(35);
위에서 보듯 데이터 타입의 크기 뿐만 아니라 Datatype도 변경이 가능 하지만 테이블 내에 데이터가 있을 경우 변경이 가능 한지 미리 확인 해야 합니다.
3. Table 컬럼명 변경
alter table [TB_NAME] rename column 컬럼명 to 변경할 컬럼명;
ex) alter table scott.test_table rename column test_col1 to test_col10;
4. Table 컬럼 삭제
alter table [TB_NAME] drop column 컬럼명;
ex) alter table scott.test_table drop column test_col1;
반응형
'ORACLE' 카테고리의 다른 글
[Oracle] Database 상황별 자료 수집 (0) | 2023.07.26 |
---|---|
Oracle Log Switch 발생량 확인 (오라클 로그스위치) DBA 쿼리 (0) | 2022.12.23 |
[Error] ORA-4031 shared memory 부족 현상 오라클 (2) | 2022.12.09 |
[SQL] undo tablespace 용량 확인 (0) | 2022.11.30 |
[SQL] unusable index 확인 (0) | 2022.11.24 |
댓글