Given the table created using:
CREATE TABLE tbl_Country ( CountryId INT NOT NULL AUTO_INCREMENT, IsDeleted bit, PRIMARY KEY (CountryId) )
How can I delete the column IsDeleted
?
Delete Selected Columns: Select multiple contiguous columns by right-clicking and pressing the Shift key. Use the Control key to select separated columns. Refresh: Update all information in the Columns subtab. Clear Default: Clear the assigned default value.
ALTER TABLE tbl_Country DROP COLUMN IsDeleted;
Here's a working example.
Note that the COLUMN
keyword is optional, as MySQL will accept just DROP IsDeleted
. Also, to drop multiple columns, you have to separate them by commas and include the DROP
for each one.
ALTER TABLE tbl_Country DROP COLUMN IsDeleted, DROP COLUMN CountryName;
This allows you to DROP
, ADD
and ALTER
multiple columns on the same table in the one statement. From the MySQL reference manual:
You can issue multiple
ADD
,ALTER
,DROP
, andCHANGE
clauses in a singleALTER TABLE
statement, separated by commas. This is a MySQL extension to standard SQL, which permits only one of each clause perALTER TABLE
statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With