几种模式的PostgreSQL请求

编程入门 行业动态 更新时间:2024-10-28 07:20:01
本文介绍了几种模式的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请求

本文发布于:2023-10-15 11:50:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1494253.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几种   模式   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!