Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL: delete all contents in the db

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anyone know of any command that clear/delete/remove all the content in the dataase (but do not touch the tables) so the end result will be empty tables.

thanks
peter
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Oracle I use to genrate the script with help of a query.
you will have to write script using truncate

Shailesh
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you show an example of a script you wrote.
thanks
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned I did same in Oracle

Select TABLE_NAME form user_tables gives me all table in schema


so I made a query like


select distinct 'Truncate table ' || TABLE_NAME || ';' from USER_TABLES;
and I saved the output of query in a sql file

Then I could execute sql file on sql plus

Shailesh
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic