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 use ALTER TABLE
statement to delete a column from the table. The syntax is as follows:
<code>ALTER TABLE table_name DROP COLUMN column_name;</code>
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 named customers
which contains the following columns:
<code>id | name | email | phone</code>
To delete the phone
column, you can use the following statement:
<code>ALTER TABLE customers DROP COLUMN phone;</code>
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!