为了删除MySQL表中的每一列,您可以使用DROP TABLE命令。以下是语法:
DROP TABLE yourTableName;
让我们首先创建一个表:
create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentLastName varchar(20), StudentAge int, StudentAddress varchar(200), StudentCountryName varchar(30), StudentDateOfBirth datetime );
让我们使用DESC命令检查表的描述:
desc DemoTable;
这将产生以下输出:
+--------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentFirstName | varchar(20) | YES | | NULL | | | StudentLastName | varchar(20) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | | StudentAddress | varchar(200) | YES | | NULL | | | StudentCountryName | varchar(30) | YES | | NULL | | | StudentDateOfBirth | datetime | YES | | NULL | | +--------------------+--------------+------+-----+---------+----------------+ 7 rows in set (0.01 sec)
以下是删除MySQL表中每一列的查询:
drop table DemoTable;
执行上述查询后,数据库中将不存在上述表。