Oracle

게시글 보기
작성자 유건데이타 등록일 2015-05-14
제목 ALTER TABLE RENAME COLUMN | CONSTRAINT (V920 NEW)
ALTER TABLE RENAME COLUMN | CONSTRAINT (V920 NEW)
=================================================


PURPOSE
-------
9i Release 2(V920)에서 소개된 ALTER TABLE RENAME COLUMN | CONSTRAINT 구문을 살펴본다.


Explanation
-----------
COLUMN NAME을 변경하는 방법은 버젼 별로 다음과 같다.

1.9i Release 1(V901) 이전
- TABLE 재생성

2. 9i Release 1(V901)
- DBMS_REDEFINITION을 이용(Bulletin No: 12279 참조)

3. 9i Release 2(V920)
아래의 문법으로 변경할 수 있다.

ALTER TABLE table_name RENAME COLUMN old_name TO new_name;

아울러 CONSTRAINT NAME도 변경할 수 있다.

ALTER TABLE table_name RENAME CONSTRAINT old_name TO new_name;


Example
-------
sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Thu Nov 7 18:21:16 2002

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> create table kyulee ( a number );

Table created.

SQL> alter table kyulee rename column a to col1;

Table altered.

SQL> desc kyulee
Name Null? Type
----------------------------------------- -------- ----------------------------
COL1 NUMBER


SQL> alter table kyulee add constraint pk_kyulee primary key (col1);

Table altered.

SQL> select constraint_name, constraint_type from user_constraints where table_name = 'KYULEE';

CONSTRAINT_NAME C
------------------------------ -
PK_KYULEE P

SQL> alter table kyulee rename constraint pk_kyulee to pk_kyulee_col1;

Table altered.


SQL> select constraint_name, constraint_type from user_constraints where table_name = 'KYULEE';

CONSTRAINT_NAME C
------------------------------ -
PK_KYULEE_COL1 P


Reference Documents
-------------------
Oracle9i SQL Reference Release 2 (9.2) Part Number A96540-01

http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96540/statements_32a.htm#2103793


Bulletin No: 12279
Product: ORACLE_SERVER
Subject: (9I) DBMS_REDIFINITION (COLUMN RENAME)
762 보기 태그:
Comment
등록된 코멘트가 없습니다.