Modify Table Structure in Oracle

Source: Internet
Author: User

1. Modify the field data type

 
Syntax:
Alter table name MODIFY (column name data type );
Eg1:
Alter table emp modify (column1 VARCHAR (10 ));
When modifying the length of a column, you can only edit a longer length than the existing field actually saves, otherwise the following error is prompted: ORA-01441: cannot reduce the column length because some values are too large

2. Add a column

Syntax: alter table name ADD (column name data type); eg1: alter table emp ADD (column1 NUMBER (38,0) not null );

3. Change the list

Syntax: alter table name rename column current COLUMN name TO new COLUMN name; eg1: alter table emp rename column column1 TO column2;

4. delete a column

Syntax: alter table table Name drop column column name; eg1: alter TABLE emp drop COLUMN column1

5. Change the table name

Syntax: alter table current table name rename to new TABLE name; eg1: alter table emp rename to emp_new

6. Add comments to the table

Comment column on table name. column name is 'comment content'; // modify comment on table emp. column1 IS 'comment content'; // Modify table comment

 

 

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.