Pages

Tuesday, 4 July 2023

How to Delete a Column in SQL

 

Problem:

You want to remove a column from a table.

Example:

We would like to delete the column description from the table product.

Solution:

ALTER TABLE product
DROP COLUMN description;

Discussion:

SQL provides the ALTER TABLE statement to change the structure of a table. If you’d like to remove a column from a table, use this statement.

First, write ALTER TABLE, followed by the name of the table you want to change (in our example, product). Next add the DROP COLUMN clause, followed by the name of the column you want to remove (in our example, description). This removes the column from the table, including any data stored in it.

Recommended courses:

Recommended articles:

See also:

No comments:

Post a Comment

Html or Xamp code to blogspot for custom coding

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html> <html lang='en' xmlns='http://www.w3....