我想知道: 如何在Oracle 10g中重命名表列?
答案 0 :(得分:104)
SQL> create table a(id number);
Table created.
SQL> alter table a rename column id to new_id;
Table altered.
SQL> desc a
Name Null? Type
----------------------------------------- -------- -----------
NEW_ID NUMBER
答案 1 :(得分:34)
查询的语法如下:
Alter table <table name> rename column <column name> to <new column name>;
示例:
Alter table employee rename column eName to empName;
要将没有空格的列名重命名为包含空格的列名:
Alter table employee rename column empName to "Emp Name";
要将包含空格的列重命名为不带空格的列名:
Alter table employee rename column "emp name" to empName;
答案 2 :(得分:19)
alter table table_name rename column oldColumn to newColumn;
答案 3 :(得分:2)
假设supply_master是一个表,并且
SQL>desc supply_master;
SQL>Name
SUPPLIER_NO
SUPPLIER_NAME
ADDRESS1
ADDRESS2
CITY
STATE
PINCODE
SQL>alter table Supply_master rename column ADDRESS1 TO ADDR;
Table altered
SQL> desc Supply_master;
Name
-----------------------
SUPPLIER_NO
SUPPLIER_NAME
ADDR ///////////this has been renamed........//////////////
ADDRESS2
CITY
STATE
PINCODE
答案 4 :(得分:0)
alter table table_name
rename column old_column_name/field_name to new_column_name/field_name;
示例:alter table student column name to username;