SQL Server INFORMATION_SCHEMA 内容

发布于 2024-11-03 03:47:37 字数 317 浏览 2 评论 0原文

在大多数RDBMS中,元模型是“自包含的”,这意味着我可以通过浏览元模型本身来找出元模型的模型。 SQL Server 似乎并非如此。我想做的是:

SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'INFORMATION_SCHEMA'

这样,我就可以发现 INFORMATION_SCHEMA 架构本身。

为了使 INFORMATION_SCHEMA 视图“自包含”,我是否必须配置任何授予/权限/登录设置?

In most RDBMS, the meta-model is "self contained", which means that I can find out the model of the meta-model by browsing the meta-model itself. This doesn't seem to be the case with SQL Server. What I want to do is this:

SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'INFORMATION_SCHEMA'

That way, I can discover the INFORMATION_SCHEMA schema itself.

Is there any grant/permission/login setting that I have to configure in order to make the INFORMATION_SCHEMA views be "self contained"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

相对绾红妆 2024-11-10 03:47:37

不要认为这是可能的。

INFORMATION_SCHEMA.TABLES 视图的定义是

CREATE VIEW [INFORMATION_SCHEMA].[TABLES]
AS 
SELECT
    DB_NAME()           AS TABLE_CATALOG,
    s.name              AS TABLE_SCHEMA,
    o.name              AS TABLE_NAME,
    CASE o.type
        WHEN 'U' THEN 'BASE TABLE'
        WHEN 'V' THEN 'VIEW'
    END             AS TABLE_TYPE
FROM
    sys.objects o LEFT JOIN sys.schemas s
    ON s.schema_id = o.schema_id
WHERE
    o.type IN ('U', 'V')

这样的,它从 sys.objects 中提取信息,但是这又不包含任何关于 INFORMATION_SCHEMA 对象的信息。

这些的元数据是通过 sys.system_objects 访问的。

Don't think this is possible.

The definition of the INFORMATION_SCHEMA.TABLES view is

CREATE VIEW [INFORMATION_SCHEMA].[TABLES]
AS 
SELECT
    DB_NAME()           AS TABLE_CATALOG,
    s.name              AS TABLE_SCHEMA,
    o.name              AS TABLE_NAME,
    CASE o.type
        WHEN 'U' THEN 'BASE TABLE'
        WHEN 'V' THEN 'VIEW'
    END             AS TABLE_TYPE
FROM
    sys.objects o LEFT JOIN sys.schemas s
    ON s.schema_id = o.schema_id
WHERE
    o.type IN ('U', 'V')

so it pulls its information from sys.objects however this in turn contains nothing about the INFORMATION_SCHEMA objects.

The metadata for these is accessed via sys.system_objects instead.

梦幻的味道 2024-11-10 03:47:37

您可以使用 sys.all_views

select SCHEMA_NAME(schema_id), name
from sys.all_views
order by 1,2

You can use sys.all_views

select SCHEMA_NAME(schema_id), name
from sys.all_views
order by 1,2
傻比既视感 2024-11-10 03:47:37
USE information_schema;
SHOW TABLES;

USE mysql;
SHOW TABLES ;
USE information_schema;
SHOW TABLES;

USE mysql;
SHOW TABLES ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文