我想知道:如何在Oracle 10g中重命名表列?
我想知道:如何在Oracle 10g中重命名表列?
Answers:
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
查询的语法如下:
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;
alter table table_name rename column oldColumn to newColumn;
假设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
alter table table_name
rename column old_column_name/field_name to new_column_name/field_name;
例: alter table student column name to username;
COLUMN
在列名之前使用关键字。