Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How can I remove every column in a table in MySQL?
In order to remove every column in a table in MySQL, you can use DROP TABLE command. Following is the syntax:
DROP TABLE yourTableName;
Let us first create a table:
mysql> 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 ); Query OK, 0 rows affected (0.85 sec)
Let us check the description of table using DESC command:
mysql> desc DemoTable;
This will produce the following output:
+--------------------+--------------+------+-----+---------+----------------+ | 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)
Following is the query to remove every column in a table in MySQL:
mysql> drop table DemoTable; Query OK, 0 rows affected (0.37 sec)
After executing the above query, the above table won’t be present in the database.
Advertisements
