Is there any way to truncate all tables from a specific MySQL database name without using any other language than SQL? I mean no linux shell scripts. (why? because it will run on windows, MacOSX and linux servers).
the problem is that the client its selecting the database name from a list in a control panel webpage (wich will be displaying MySQL databases from different servers *nix and windows), and then he will want to truncate all the tables inside that database (yes that is the main task of the web form).
Alex
Ok, I solved it by myself here is the stored procedure 🙂
What I am making its calling all tables from the given database, this will help if the tables inside the given database have no pattern to follow.
So by calling
DECLARE c1 CURSOR FOR SELECT Concat('TRUNCATE TABLE ', TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES WHERE INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = "@DatabaseName";and saving results into a cursor I can fetch all theTRUNCATE TABLE xstatements generated by the “n” quantity of tables inside the given database, then by just preparing and executing each statement in the cursor it will truncate all the tables inside the given database.Hope this helps someone else too 🙂
Alex