Oracle

重命名分區表中的列

  • June 17, 2018

我想重命名分區表中的列。oracle 會為所有分區執行此操作嗎?這種變化有什麼特別之處嗎?

重命名列是一個簡單的字典更新。是的,它將為所有分區完成。

SQL> CREATE TABLE t1 (
      c1   NUMBER,
      c2   VARCHAR2(30),
      c3   NUMBER,
      c4   NUMBER, constraint t1_pk primary key (c1, c4) using index local)
 PARTITION BY LIST (c4) (
      PARTITION p10 VALUES (10),
      PARTITION p20 VALUES (20),
      PARTITION p30 VALUES (30,40));

Table created.

SQL> alter table t1 rename column c2 to c5;

Table altered.

SQL> alter table t1 rename column c4 to c6;

Table altered.

SQL> alter table t1 rename column c1 to c7;

Table altered.

SQL> desc t1
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
C7                                        NOT NULL NUMBER
C5                                                 VARCHAR2(30)
C3                                                 NUMBER
C6                                        NOT NULL NUMBER

引用自:https://dba.stackexchange.com/questions/209851