Alter Table Statement Or Command In Oracle

'Alter '

In Oracle alter is command or statement that is used to perform a different type of operation in any database.  Alter command mainly use for add a column, delete a column, modify a column and also rename a table in any database. 

The ALTER command require exclusive access to the database object. And the main important point is that an ALTER TABLE command fails if another user has an open transaction on that particular table.

Uses of alter command:

1. Add a column in a table
Syntax :  alter table table_name add column_name datatype(size);

2. Add multiple columns in a table
Syntax :   alter table table_name add (column_name1 datatype(size), column_name2 datatype(size), ………);

3. delete a column in a table
Syntax :   alter table table_name drop column column_name;

4. Modify Column in a table (change the data type of a column)
Syntax :   alter table table_name alter column column_name datatype(size);

5. Modify Multiple columns in a table
Syntax:   alter table table_name modify (column_name1 datatype(size), column_name2 datatype(size), ………);

6. Rename column in a table
Syntax :   alter table table_name rename column old_name to new_name;

7. Alter command is also used for renaming the table name in your database
Syntax:   alter table old_table_name rename new_table_name;

Last updated:7/19/2018 12:47:34 AM
Arti Mishra

Arti Mishra



Leave Comment