In SQL, the syntax for using the ALTER TABLE statement to delete a table column is: ALTER TABLE table_name DROP COLUMN column_name. This statement permanently deletes all data in the specified column. If the column is part of a foreign key, unique constraint, or primary key, the associated constraints must also be deleted.
SQL statement to delete a column
In SQL, you can useALTER TABLE
statement to delete a column from the table. The syntax is as follows:
ALTER TABLE table_name DROP COLUMN column_name;
Among them:
table_name
is the name of the table where the column is to be deleted.column_name
is the name of the column to be deleted.Example
Suppose we have a table namedcustomers
which contains the following columns:
id | name | email | phone
To delete thephone
column, you can use the following statement:
ALTER TABLE customers DROP COLUMN phone;
Note:
The above is the detailed content of statement to delete column in sql. For more information, please follow other related articles on the PHP Chinese website!