如何在 Oracle 10g 中重命名表列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13878383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:44:53  来源:igfitidea点击:

How to rename a table column in Oracle 10g

oracleoracle10g

提问by Arvind Lairenjam

I would like to know: How to rename a table column in Oracle 10g?

我想知道:如何在 Oracle 10g 中重命名表列?

回答by DazzaL

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

回答by Praveen Vinny

The syntax of the query is as follows:

查询的语法如下:

Alter table <table name> rename column <column name> to <new column name>;

Example:

例子:

Alter table employee rename column eName to empName;

To rename a column name without space to a column name with space:

要将不带空格的列名重命名为带空格的列名:

Alter table employee rename column empName to "Emp Name";

To rename a column with space to a column name without space:

要将带空格的列重命名为不带空格的列名:

Alter table employee rename column "emp name" to empName;

回答by Srinivas B

alter table table_name rename column oldColumn to newColumn;

回答by Narayan

suppose supply_master is a table, and

假设 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                  

回答by Gudddu kumar

alter table table_name 
rename column old_column_name/field_name to new_column_name/field_name;

example: alter table student column name to username;

例子: alter table student column name to username;