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