我有一个数据库,每个用户都有一个模式。
I have a database, with every users having a schema.
有没有一种方法可以查询每个模式中的表?
Is there a way to query a table in every schema?
类似以下操作: 选择ID,*。simulation中的名称 不起作用...
Something like: select id, name from *.simulation doesn't work...
谢谢您的帮助!
推荐答案否,您将需要编写一个函数-使用您使用的任何一种语言的服务器端函数或客户端函数-对每个模式执行一次查询。
No, you will need to write a function - either a server side function or a client side function in whatever language you're using - that executes the query once for each schema.
您还可以创建一个在所有模式之间执行UNION ALL的VIEW,但是如果要动态添加和删除模式,则将需要进行大量维护。
You could also create a VIEW that does UNION ALL between all the schemas, but that's going to be a lot of work to maintain if your schemas are dynamically added and removed.
更多推荐
几种模式的PostgreSQL请求
发布评论