Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:35:57+00:00 2026-05-27T06:35:57+00:00

is there a way to apply a query to each table in a mysql

  • 0

is there a way to apply a query to each table in a mysql database?

Something like

SELECT count(*) FROM {ALL TABLES}
-- gives the number of count(*) in each Table

and

DELETE FROM {ALL TABLES}
-- Like DELETE FROM TABLE applied on each Table
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:35:58+00:00Added an answer on May 27, 2026 at 6:35 am
    select sum(table_rows) as total_rows
    from information_schema.tables
    where table_schema = 'your_db_name'
    

    beware this is just an approximate value

    In order to delete the contents of all your tables you can do something like this

    select concat('truncate ',table_name,';')
    from information_schema.tables
    where table_schema = 'your_db_name'
    

    Then run the output of this query.

    UPDATE.

    This is a stored procedure to apply truncate table to all tables in a specific 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');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query that looks like this: UPDATE `Table` SET `Column` =
Is there any way to apply an attribute to a model file in ASP.NET
Is there the way to apply greedy behavior to and keys in Visual Studio?
Is there a way to apply import for a particular imported file and not
Is there a way to apply bitmapeffects within a silverlight web project.
Is there a way to apply consistent visual appearance for multiple Windows Forms applications?
Is there a way I can apply '+ to '( 1 2 3)? edit:
Is there any possible way to apply more than CSS to a control through
Is there a way I can apply the login_required decorator to an entire app?
In C/C++, is there an easy way to apply bitwise operators (specifically left/right shifts)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.