几种模式的PostgreSQL请求 [英] postgresql request over several schema

查看:116
本文介绍了几种模式的PostgreSQL请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,每个用户都有一个模式。

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请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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