tags:

views:

35

answers:

2

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?

+5  A: 

DROP TABLE table

Svisstack
+4  A: 

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.

martin clayton
So in other words it might be easier just to recreate the table once I know which fields I need?
SimpleCoder
@SimpleCoder - That's right.
martin clayton
Got it, thanks! I don't know what I was thinking when I thought a table with no columns could exist.
SimpleCoder