Bug #61890 truncate if exists
Submitted: 17 Jul 2011 4:25 Modified: 17 Jul 2011 7:33
Reporter: Richard Lynch Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: DDL Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Triage: Needs Triage: D5 (Feature request)

[17 Jul 2011 4:25] Richard Lynch
I have a series of SQL statements in 'init.sql' that creates all the tables with "create if not exists" and initializes some tuples with insert ignore.

I have another script 'reset.sql' that truncates everything, for when I make changes during development.

The general process is:
\. reset.sql
\. init.sql

Or, for a new developer, just:
\. init.sql

Alas, if they an existing developer does a checkout, and wants to start from a known state, and tables have been added, they have to do:
\. init.sql
\. reset.sql
\. init.sql
because the "truncate" statements would fail for tables that don't exist.

It would be Really Nifty (tm) if "truncate if exists" were supported, for this use case.

How to repeat:
truncate foo;
[17 Jul 2011 7:33] Valeriy Kravchuk
Thank you for the feature request.