如何使用SQL在Informix中列出特定数据库的模式? [英] How to list schemas of a specific database in Informix using SQL?

查看:160
本文介绍了如何使用SQL在Informix中列出特定数据库的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在Informix中的特定数据库中获取模式名称列表的查询是什么?

What is the query to get a list of schemas names in a specific database in Informix?

推荐答案

模式属于用户。您可以从 sysusers 系统目录

A schema belongs to a user. You can list all available users from the sysusers system catalog :

SELECT username FROM "informix".sysusers;

因为只有 DBA s和资源特权允许用户发布 创建模式语句,我们可以像这样限制查询:

Since only DBAs and Resource privilieges allow a user to issue a CREATE SCHEMA statement, we could restrict the query like :

SELECT username FROM "informix".sysusers WHERE usertype IN ('D', 'R');






另一种解决方案是只列出实际拥有创建表;为此,您可以查询 systables 系统目录并列出不同的所有者。


Another solution is to list only users that actually have created tables ; for that, you can query the systables system catalog and list distinct owners.

SELECT DISTINCT owner FROM FROM "informix".systables

如@JonathanLeffler所评论的,可以授予用户 RESOURCE 特权并创建了一个表,然后将其降级为 CONNECT 特权。用户仍将拥有该表。因此,第二种解决方案是最准确的。

As commented by @JonathanLeffler, a user could have been granted RESOURCE privileges and have created a table, and then be 'demoted' to CONNECT privileges. The user would still own the table. Hence the second solution is the most accurate.

这篇关于如何使用SQL在Informix中列出特定数据库的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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