Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Oracle Concepts - Altering Tables

Oracle Tips by Burleson Consulting

Altering Tables

Having created tables, you will find there are times that you will want to alter them in some respect. This is done with the alter table command. Some things you might find you need to do with the alter table command include:

* Moving a table to another tablespace

* Adding a column to the table

* Dropping a column from the table

* Changing a column name

* Modify existing constraints or add new constraints

For example, we might want to move the BOOKS table to another tablespace. The alter table command allows us to do this easily:

ALTER TABLE books MOVE TABLESPACE new_users;

You can add a column to a table with the alter table command. In this case, we are adding a column called BOOK_PRICE to the BOOKS table. This column is a number data type:

ALTER TABLE books ADD book_price NUMBER;

You can add multiple columns too as seen in this example where we add a column called BOOK_PUB_NO and BOOK_ALT_TITLE to the BOOKS table:

ALTER TABLE
   books
ADD
(
   book_pub_no    NUMBER,
   book_alt_title VARCHAR2(50)
);

It used to be in Oracle that renaming or removing a column from a table was a big deal. You actually had to save the data, drop and re-create the table which can have a horrible impact if it?s a big table in a production environment. Now, you can rename or drop columns from a table with the alter table command.

We demonstrate renaming and dropping a column in the following example. First we rename the BOOK_ISBN column to ISBN_NUMBER. In the second example we drop the BOOK_PUB_NO column:

ALTER TABLE books RENAME COLUMN book_isbn TO isbn_number;

ALTER TABLE books DROP COLUMN book_pub_no;

We discussed primary key constraints earlier in this section. Oracle actually has a number of different constraint types that we will cover in more detail later in this section. However, we should take a moment to see how you can rename a constraint with the alter table command:

ALTER TABLE books
RENAME CONSTRAINT pk_books TO pk_book;

This is an excerpt from the bestselling "Easy Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle Certified Master).  It?s only $19.95 when you buy it directly from the publisher here.

If you like Oracle tuning, you may enjoy the new book "Oracle Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning tips & scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.