Oracle alter table structure statement

Source: Internet
Author: User
1. MODIFY a table field: MODIFY the Data Type of a column (generally, the length is limited and there are many restrictions when it is changed to a different type): Syntax: ALTERTABLE table name MODIFY (

1. MODIFY a TABLE field: MODIFY the Data Type of a column (generally limited to the modification length. There are many restrictions when changing to a different type): Syntax: alter table name MODIFY (

1. Modify the table fields:

Modify the Data Type of a column (generally limited to the modification length. There are many restrictions when changing to a different type ):

Syntax: alter table name MODIFY (column name data type );

Eg1: alter table skate_test modify (author number (10, 0 ));

When modifying the column length, you can only change it to a longer length than the existing field actually saves; otherwise, the following error is prompted:

ORA-01441: cannot reduce column length because some values are too large

Eg2: alter table skate_test modify (author varchar2 (10 ))

When modifying the Data Type of a column, the modified column must be empty; otherwise, the following error is prompted:

ORA-01439: to change the data type, the column to be modified must be empty

2. Add a column:

Syntax: alter table name ADD (column name data type );

Eg1: alter table skate_test ADD (author NUMBER (38,0) not null );

3. Change the column Name:

Syntax: alter table name rename column current COLUMN name TO new COLUMN name;

Eg1: alter table skate_test rename column author TO authorer_new;

4. delete a column:

Syntax: alter table Name drop column name;

Eg1: alter table skate_test drop column author;

5. Modify the table name:

Syntax: alter table current TABLE name rename to new TABLE name;

Eg1: alter table skate_test rename to test_sakte

6. Add notes to the table:

Syntax: comment on column table name. column name is 'comment content'; // modify the comment of a table column

Eg1: comment on column MOVO_NEW.TEST_SAKTE IS 'comment content'; // modify the 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.