alle Tabellen eines bestimmten Musters aus einer Datenbank löschen

/ Published in: MySQL
Save to your folder(s)

drop_tables_like(pattern, db)

Copy this code and paste it in your HTML
  1. use osamos2;
  2. delimiter $$
  3. create procedure drop_tables_like(pattern varchar(255), db varchar(255))
  4. select @str_sql:=concat('drop table ', group_concat(table_name))
  5. from information_schema.tables
  6. where table_schema=db and table_name like pattern;
  8. prepare stmt from @str_sql;
  9. execute stmt;
  10. drop prepare stmt;
  11. end$$
  13. call drop_tables_like('ALT_%', 'osamos2')$$
  15. drop procedure if exists drop_tables_like$$
  16. delimiter ;

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.