

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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 do I alter a MySQL table column defaults?
- How do I remove a uniqueness constraint from a MySQL table?
- How can I change the name of an existing column from a MySQL table?
- How can I delete MySQL temporary table?
- How can I remove a value from an enum in MySQL?
- 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 can I create a MySQL table with a column with only 3 possible given values?
- Can I define a column as a table type in SAP HANA?
- Can we add a column to a table from another table in MySQL?
- Can we remove a primary key from MySQL table?
Advertisements