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 7515931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:58:11+00:00 2026-05-30T00:58:11+00:00

Suppose I have a database data1 which gives me this: show tables; table1 table2

  • 0

Suppose I have a database data1 which gives me this:

show tables;


table1

table2

table3


Now instead of individually executing “select * from each table” i want to create a procedure which goes through each database shown in “show databases;” resultset, and then executes select * from each table of that database. I thought of using cursors which would scroll down the resultset, hold each database name in a variable and then execute select statement on each table of that database traversing in the same way. Can someone kindly help me out with how to use cursors in this case, as i am only aware of using cursors for SELECT and UPDATE statements.

btw i use MYSQL.

  • 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-30T00:58:13+00:00Added an answer on May 30, 2026 at 12:58 am

    I’ll refrain from asking why you would do this. Here is a general strategy in pseudocode;

    [words in parentheses are (SQL commands and tables) which will run on your mySQL server.]

    Connect to your mySQL server with your favourite tool/programming language and:

    -- (USE information_schema;)
    
    for db in (select distinct table_schema from tables;)
    do:    
        for table in (select table_name from tables where table_schema='$db';)
        do:
            select field,column,attribute from $table;
        done
    done
    

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have 2 tables in a database. eg: Dog & Boss This is
Suppose I have a big database, about 800 tables. In this database there is
Suppose I have a database like this: This is set up to give role-wise
Suppose I have some application A with a database. Now I want to add
Suppose the following: I have a database set up on database.mywebsite.com , which resolves
Suppose I have two tables on a database, T 10 and T 11 ,
Suppose I have a custom file format, which can be analogous to N tables.
Suppose I have a database containing 3 tables in a grails application: User Activity
Suppose I have a database which contains blog posts which have tags and I
Suppose you have an database with the largest tables containing about 200.000 rows, and

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.