4

I simply want to drop the table 'whatever' if it exist and then recreate table 'whatever' in a single query if possible.

DROP TABLE IF EXISTS `whatever` ELSE
    CREATE TABLE `whatever`

Any idea ?

Kara
  • 6,115
  • 16
  • 50
  • 57
capte
  • 207
  • 1
  • 3
  • 9

1 Answers1

6
CREATE TABLE `whatever` IF NOT EXISTS ELSE TRUNCATE `whatever`

Use TRUNCATE to empty the table and reset cardinality instead of deleting the table and recreating it.

Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144
  • This doesn't work for me. My MySQL version is 5.5.17. How can I get this running ? – M-D Oct 02 '13 at 08:12