使用
检索表#+begin_src sql :engine mysql :dbuser org :database grocer
show tables;
#+end_src
#+RESULTS:
| Tables_in_grocer |
|------------------|
| Customers |
| OrderItems |
| Orders |
| Products |
| Vendors |
然后依次查看每个表
select * from Vendors;
select * from Products;
select * from Customers;
select * from Orders;
select * from OrderItems;
是否可以将循环用作
for table in tables
select * from table;
答案 0 :(得分:1)
也许是这样? (如果您只需要查询)
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;
如果您希望直接访问结果,我认为您可以将其提取到CSV文件(How to output MySQL query results in CSV format?)
为此,您只需修改查询生成器并执行生成的代码即可。