0

Retrieve the tables with

#+begin_src sql :engine mysql :dbuser org :database grocer
show tables;
#+end_src

#+RESULTS:
| Tables_in_grocer |
|------------------|
| Customers        |
| OrderItems       |
| Orders           |
| Products         |
| Vendors          |

Then rview each table one by one

select * from Vendors; 
select * from Products;
select * from Customers;
select * from Orders;
select * from OrderItems;

Is it possible to take advantage of loop as

for table in tables
    select * from table;
Alice
  • 1,360
  • 2
  • 13
  • 28
  • Do you mean to say you want to create `select` statement for all available tables? – Arun Palanisamy Dec 05 '19 at 07:45
  • yes, that' s I want. @ArunPalanisamy – Alice Dec 05 '19 at 08:15
  • why do you want to do that? In which shape do you want your results in the end? Could you add a sample of the data you have and the data you want in the end? – Jaisus Dec 05 '19 at 09:15
  • I simply want to quick view the tables @Jaisus – Alice Dec 05 '19 at 09:21
  • Okay but do you want to have all your data on only one support or can you run queries one by one? If you have something that write the queries for you and after that you just have to launch them: would it be enough? – Jaisus Dec 05 '19 at 09:33

1 Answers1

1

Maybe something like this? (if you just need the queries of course)

select CONCAT('SELECT * FROM ',table_name,';')
from information_schema.tables
where table_type = 'BASE TABLE'
    and table_schema = 'your_schema_name'
order by table_schema, table_name;

If you want the results directly accessible I think you can extract them on CSV files (How to output MySQL query results in CSV format?)

For that you just have to modify a little bit the query generator and execute the resulting code.

Jaisus
  • 1,019
  • 5
  • 14