Database Reference
In-Depth Information
Quantity Number
Sell_price Item price
Modifying Tables Structure
Modifying the structure of a table is done with the ALTER TABLE command. There are
three basic things that can be modified: columns, column constraints, and table constraints.
ALTER TABLE, statement may varies from one DBMS to another. Making alteration to
existing tables is neither simple nor consistent. A user can add new column or modify ex-
isting column. To change a table using ALTER TABLE, the following information must be
must specified:
 The table must exist and the name of the table to be altered after the keywords
ALTER TABLE.
 The list of changes to be made.
Adding and Dropping New Column
Syntax:
ALTER TABLE tablename
ADD columnname data type( size);
Or
ALTER TABLE tablename
DROP COLUMN columnname ;
Example: Add another column branch to table student
Sol: ALTER TABLE Student
ADD Branch varchar( 15);
Example: Delete a column Phone from table Staff
Sol: ALTER TABLE Staff
DROP COLUMN Phone;
Modifying Existing Column
Syntax:
ALTER TABLE tablename
MODIFY ( columnname newdatatype( new size));
Example: Modify table student on column branch
Sol: ALTER TABLE Student
MODIFY( Branch varchar( 20);
Deleting Tables
Search WWH ::




Custom Search