Return to Snippet

Revision: 44746
at April 17, 2011 06:41 by abstraktor


Initial Code
use osamos2;
delimiter $$
create procedure drop_tables_like(pattern varchar(255), db varchar(255))
begin
select @str_sql:=concat('drop table ', group_concat(table_name))
from information_schema.tables
where table_schema=db and table_name like pattern;

prepare stmt from @str_sql;
execute stmt;
drop prepare stmt;
end$$

call drop_tables_like('ALT_%', 'osamos2')$$

drop procedure if exists drop_tables_like$$
delimiter ;

Initial URL

                                

Initial Description
drop_tables_like(pattern, db)

Initial Title
alle Tabellen eines bestimmten Musters aus einer Datenbank löschen

Initial Tags
sql

Initial Language
MySQL