select sum(table_rows) as total_rows
from information_schema.tables
where table_schema = 'your_db_name'
pas på, at dette kun er en omtrentlig værdi
For at slette indholdet af alle dine tabeller kan du gøre sådan noget
select concat('truncate ',table_name,';')
from information_schema.tables
where table_schema = 'your_db_name'
Kør derefter outputtet af denne forespørgsel.
OPDATERING.
Dette er en lagret procedure til at anvende truncate table
til alle tabeller i en bestemt database
delimiter //
drop procedure if exists delete_contents //
create procedure delete_contents (in db_name varchar(100))
begin
declare finish int default 0;
declare tab varchar(100);
declare cur_tables cursor for select table_name from information_schema.tables where table_schema = db_name and table_type = 'base table';
declare continue handler for not found set finish = 1;
open cur_tables;
my_loop:loop
fetch cur_tables into tab;
if finish = 1 then
leave my_loop;
end if;
set @str = concat('truncate ', tab);
prepare stmt from @str;
execute stmt;
deallocate prepare stmt;
end loop;
close cur_tables;
end; //
delimiter ;
call delete_contents('your_db_name');