Oracle ALTER TABLE 语句

2024 年 8 月 29 日 | 阅读 2 分钟

在 Oracle 中,ALTER TABLE 语句指定如何在表中添加、修改、删除或删除列。 它也用于重命名表。

如何在表中添加列

语法

示例

假设已经存在表 customers。 现在,将新列 customer_age 添加到表 customers 中。

现在,新列 "customer_age" 将被添加到 customers 表中。

如何向现有表中添加多列

语法

示例

Now, two columns customer_type and customer_address will be added in the table customers.

如何修改表的列

语法

示例

Now the column column_name in the customers table is modified
to varchar2 (100) and forced the column to not allow null values. 

如何修改表中的多列

语法

示例

This will modify both the customer_name and city columns in the table. 

如何删除表的列

语法

示例

This will drop the customer_name column from the table.

如何重命名表的列

语法

示例

This will rename the column customer_name into cname.

如何重命名表

语法

示例

This will rename the customer table into "retailers" table. 
下一个主题Oracle DROP TABLE