Oracle adds, modifies, deletes, renames columns

Source: Internet
Author: User

Because Oracle has a slightly different format for adding and deleting columns, it is hereby documented for easy viewing later.

1. Add Columns:

Sql> ALTER TABLE t1 add y integer;

Table Altered

Executed in 0.046 seconds

Description: Added column format for ALTER TABLE name add new column name data type;


2. Delete Columns

sql> ALTER TABLE t1 drop column y;

Table Altered

Executed in 0.015 seconds


Description: Delete a column separately in the format of the ALTER TABLE table name drop column name;


3. Modify Columns

sql>alter Table T1 Modify I number (10);

Description: The format of the modified column is the ALTER TABLE table name modify column name data type;

Special attention : If you want to change the column data type, you need to back up the column data before conversion, or the change will fail!


4. Renaming columns

sql> ALTER TABLE T1 rename column I to x;

Table Altered

Executed in 0.062 seconds


Description: Rename the column in the format ALTER TABLE name rename column name to new column name;


5. Delete multiple columns


Sql> ALTER TABLE t drop (A, b);

Table Altered

Executed in 1.56 seconds


Description: Delete multiple columns simultaneously in the format ALTER TABLE name drop (column name 1, column name 2,.... Column name N);

It is also important to note that deleting multiple columns at the same time does not delete all the columns in the table, and it does not make sense to delete the table.


Finally, a little bit of contempt for Oracle's developers, SQL command statement format is not standard, too casual!



Oracle Add, modify, delete, rename columns

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.