Several ways that Oracle modifies table and column names

Source: Internet
Author: User

Renaming a tableFor tables that already exist, you can also modify their names. There are two syntactic forms of renaming a table, one
is to use the ALTER TABLE statement with the following syntax:

ALTER TABLE table_name RENAME to new_table_name;

The other is to use the rename statement directly, the syntax is as follows:

RENAME table_name to New_table_name; Modify the name of a column
The syntax for modifying the names of columns in a table is as follows:

ALTER TABLE table_name RENAME COLUMN column_name to New_column_name;

For example, modify the name of the birthday column in the person table to age, as follows:

sql> ALTER TABLE person RENAME COLUMN birthday to age;

The table has changed.
Modifying the data type of a column
The syntax for modifying the data type of a column in a table is as follows:


ALTER TABLE table_name MODIFY COLUMN_NAME new_data_type; If you modify the data type of the age column in the person table to number (4), as follows:


sql> ALTER Table Person MODIFY The Age number (4) and the table has changed.
NOTE: Use the alter ... modify here, and note the alter ... add that modifies the table-level constraints of Oracle, don't confuse it.
Delete Column
When you delete a column in a table, you can delete one column at a time and delete multiple columns at once.
Delete one column at a time
The syntax form is as follows:
ALTER TABLE table_name DROP COLUMN column_name;

The syntax for deleting multiple columns at a time is as follows:
ALTER TABLE table_name DROP (column_name, ...);
By comparing the two syntaxes, you need to use the column keyword when deleting a column, and delete
Multiple columns are not required. Note: When you delete an Oracle table-level constraint, the use of the alter ... drop, when you delete a column-level constraint (NOT NULL), uses the alter ... modify

Several ways that Oracle modifies table and column names

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.