
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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.
- Related Articles
- How can we remove a column from MySQL table?
- How can I drop an existing column from a MySQL table?
- How can I use MySQL INTERVAL() function with a column of a table?
- How can we remove NOT NULL constraint from a column of an existing MySQL table?
- How can we remove PRIMARY KEY constraint from a column of an existing MySQL table?
- How can we remove FOREIGN KEY constraint from a column of an existing MySQL table?
- How do I alter a MySQL table column defaults?
- How can I change the name of an existing column from a MySQL table?
- How can I make a table in MySQL called “order”?
- How can I remove a value from an enum in MySQL?
- How do I remove a uniqueness constraint from a MySQL table?
- How can we put comments in a column of existing MySQL table?
- How can I create a MySQL table with a column with only 3 possible given values?
- Can we add a column to a table from another table in MySQL?
- How do I change the case on every field in a MySQL table in a single call?

Advertisements