Chris Laplante
Chris Laplante

Reputation: 29658

How can I remove every column in a table in MySQL?

In MySQL, is there a way to drop every field in my table, short of using:

ALTER TABLE `table`
    DROP COLUMN d1,
    DROP COLUMN d1,
    etc....

Almost like TRUNCATE for fields maybe?

Upvotes: 6

Views: 13370

Answers (2)

martin clayton
martin clayton

Reputation: 78125

You'll get an error when you try to drop the last column:

ERROR 1090 (42000): You can't delete all columns with ALTER TABLE; use DROP TABLE instead

Says it all! There's no way to have a table with zero columns.

Upvotes: 14

Svisstack
Svisstack

Reputation: 16616

DROP TABLE table

Upvotes: 9

Related Questions