Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle ALTER Statement      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: ALTER

Definition:
The Oracle ALTER statement allows you to make changes to an existing table. It is also used to add, modify, or drop a column from an existing table. The basic syntax for renaming a table is:

ALTER TABLE table_old_name
RENAME TO table_new_name;


To add a column to a table, the syntax is:

ALTER TABLE table_name
ADD column_name column-definition;


For example:

ALTER TABLE users
ADD user_name varchar2(50);


You may add multiple columns with a single ALTER statement. Each column must have its own definition.

The ALTER TABLE syntax to DROP a column is:

ALTER TABLE table_name
DROP COLUMN column_name;


For example:

ALTER TABLE users
DROP COLUMN user_name;


In Oracle 9i and above, you can use the ALTER statement along with the RENAME statement to change the name of a table column. Example syntax is shown here:

ALTER TABLE users
RENAME COLUMN first_name TO user_first_name;


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 189 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?