Home > Database > Oracle > body text

How to modify the name of a table in Oracle

青灯夜游
Release: 2021-12-24 14:40:09
Original
38427 people have browsed it

How to modify the table name in oracle: 1. Use the "ALTER TABLE table_name RENAME TO new_table_name;" statement; 2. Use the "RENAME table_name TO new_table_name;" statement.

How to modify the name of a table in Oracle

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

oracle modifies the name of the table (renames the table)

For an existing table, you can also modify its name. There are two syntax forms for renaming a table:

  • One is to use the ALTER TABLE statement, the syntax is as follows:

ALTER TABLE table_name RENAME TO new_table_name;
Copy after login
  • The other is to use the RENAME statement directly, the syntax is as follows:

RENAME table_name TO new_table_name;
Copy after login

Expand knowledge:

  • Modify the name of the column

The syntax for modifying the name of the column in the table is as follows:

ALTER TABLE table_name RENAME COLUMN column_name TO new_column_name;
Copy after login

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

SQL> ALTER TABLE person RENAME COLUMN birthday TO age;
Copy after login

The table has been changed.

  • Modify 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;
Copy after login

For example, change the data type of the age column in the person table to NUMBER(4), as follows:

SQL> ALTER TABLE person MODIFY age NUMBER(4);
Copy after login

The table has been changed.

Note: The alter ... modify used here should be distinguished from the alter ... add used to modify Oracle's table-level constraints. Don't get confused.

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of How to modify the name of a table in Oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!