Alter Table Command
We can change structure of a table (adding or removing columns) using DDL Command
- ALTER TABLE
Adding columns to existing table
Syntax:
ALTER TABLE <table name> ADD (<column name> data type [Column
constraints]);
Example: Altering the above table by adding new columns, mark1 and mark2.
Alter table student add (mark1 int);
Alter table student add (mark2 int2 not null);
To Modify an existing column
Syntax:
ALTER TABLE <table name> MODIFY(<Column Name> <new data type> [(<new size>));
Eg:- ALTER TABLE student MODIFY( division int);
2. Drop Table Command
We can delete a table using DDL command DROP TABLE
This Command is used to delete a table from database
E.g.: drop table student;
No comments:
Post a Comment