Oracle SQL in 10 Minutes - Asim Abbasi

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Chapter 6: CREATE, ALTER & DROP Statement

Page #: 1 | 2 | 3 | 4


ALTER TABLE Statement:

Figure 14: Altering the Table Structure: The ALTER TABLE statement variations.
________________________________________

 

Once you have created a table you can alter its structure using the ALTER TABLE statement. You can add column, modify the attributes of columns e.g. data type, attach a constraint, rename a column or even drop it. All these tasks can be performed with an ALTER TABLE statement as shown in the slide.

Do keep in the back of your mind that these modifications are 100% possible when you are not having any data inside the table but for cases where you already have data you cannot perform certain task e.g if the NUMBER column already contains data you cannot decrease its size etc.

Example:

ALTER TABLE customers
RENAME COLUMN limit TO amount;

Chapter 6: CREATE, ALTER & DROP Statement

Page #: 1 | 2 | 3 | 4

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Share with others: