从所有表中选择 [英] Select from all tables

查看:69
本文介绍了从所有表中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有很多表都具有相同的结构.我想从所有表格中进行选择,而不必像这样列出所有表格:

I have a lot of tables in my data base all with same structure. I want to select from all tables without having to list them all like so:

SELECT name FROM table1,table2,table3,table4

我尝试了,但这不起作用:

And I tried but this doesn't work:

SELECT name FROM *

是否可以在不列出查询中每个表的情况下选择数据库中的所有表?

Is there a way to select all tables in a database without listing each table in the query?

推荐答案

我正在使用在线文件浏览器,每个目录都有自己的表

i am working on a online file browser, each directory has its own table

由于一个原因,它非常无用:当您有大约200个文件时(这种情况是真实的,是吗?),您有大约200个表.并且,如果每个目录中大约有数千个文件,等等.在某些时候,从数据库中进行选择时,您要么处理缓慢,要么必须购买更多服务器资源.

It is very unuseful due to one reason: when you have about 200 files (this situation is real, yeah?) you have about 200 tables. And if there are about thousand files in each directory.. etc. In some time you will either have slow processing while selecting from your database either have to buy more server resources.

我认为您应该更改数据库结构:从向表中添加parent_folder_id列开始,此后您可以放置​​所有行(文件和目录-因为目录也是文件-在这里您可以添加将type列确定为一个).

I think you should change your database structure: just begin from adding parent_folder_id column to your table, after this you can put all your rows (files and directories -- because directory is a file too -- here you can add type column to determine this) into the one table.

这篇关于从所有表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆