Here is the format which can be used to remove one or more columns from an already existing table:
ALTER TABLE table-name
DROP COLUMN column-name1,
DROP COLUMN column-name2,
DROP COLUMN coloumn-name3
Now lets implement it with a table Student which have following fields:
ID,
First Name,
Last Name,
Middle Name,
Address
Lets say we want to remove Middle Name
So we will use the following query:
ALTER TABLE Student
DROP COLUMN Middle Name
Lets say we want to delete both Middle Name and Address then we use this query:
ALTER TABLE Student
DROP COLUMN Middle Name,
DROP COLUMN Address
Hope you have got the idea how to delete the columns from an existing table.
ALTER TABLE table-name
DROP COLUMN column-name1,
DROP COLUMN column-name2,
DROP COLUMN coloumn-name3
Now lets implement it with a table Student which have following fields:
ID,
First Name,
Last Name,
Middle Name,
Address
Lets say we want to remove Middle Name
So we will use the following query:
ALTER TABLE Student
DROP COLUMN Middle Name
Lets say we want to delete both Middle Name and Address then we use this query:
ALTER TABLE Student
DROP COLUMN Middle Name,
DROP COLUMN Address
Hope you have got the idea how to delete the columns from an existing table.
No comments:
Post a Comment