본문 바로가기

데이터베이스/Oracle

오라클 데이터가 있는 컬럼 길이 변경

SELECT * FROM target_table

//컬럼크기조회
SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = ' target_table' AND COLUMN_NAME='target_column'

//임시컬럼생성
alter table target_table add ( target_column2 VARCHAR(4000));

//임시컬럼에 자료백업
update target_table set target_column2= target_column;
 
//원래컬럼은 빈값으로 
update target_table  set target_column = '';

//원래컬럼 길이 수정
ALTER TABLE target_table  MODIFY( target_column VARCHAR(4000));

//백업된 컬럼 다시 넣어주기
update target_table  set target_column = target_column2;

//임시컬럼 삭제
alter table target_table  drop column target_column2;

'데이터베이스 > Oracle' 카테고리의 다른 글

오라클 다운로드  (0) 2020.05.19