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:
None 
Category:MySQL Server: DDL Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[17 Jul 2011 4:25] Richard Lynch
Description:
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.
[20 Nov 2020 7:05] MySQL Verification Team
Bug #101689 marked as duplicate of this one