| Lesson 7 | Altering a table |
| Objective | Modify a table by adding or modifying columns. |
One of the great virtues of a relational database is its flexibility.
Once you create a table in your Oracle database, you can change certain aspects of the table with the
ALTER TABLE SQL
command.
What the ALTER TABLE can and cannot do
With the ALTER TABLE command, you can change many aspects of an existing table structure. You can:
You can also modify other attributes of a table, such as the partitioning or parallelism associated with the table.
The ALTER TABLE command, however, cannot drop a column from an existing table.
Syntax for ALTER TABLE command
-
Rename the table
-
Add a column to an existing table
-
Change the attributes of a column, such as the size, data type, or default value of the column
-
Modify the storage characteristics of the table
- Add or change integrity constraints on the table
You can also modify other attributes of a table, such as the partitioning or parallelism associated with the table.
The ALTER TABLE command, however, cannot drop a column from an existing table.
There is a wide range of syntactical options for the
ALTER TABLE SQL command, reflecting the many types of modifications you
can enact with the command.
The basic syntax for the command is shown in the MouseOver below:
The basic syntax for the command is shown in the MouseOver below:
Alter Table Command
The next lesson shows how to delete a table from your Oracle database.
The next lesson shows how to delete a table from your Oracle database.