列出表名称,所有者,架构和SQL Server数据库中的列

编程入门 行业动态 更新时间:2024-10-23 19:27:16
本文介绍了列出表名称,所有者,架构和SQL Server数据库中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在SQL SERVER中,如何获取所有表名,列名和所有者的列表? 我已经做到了,但是在哪里可以获得所有者详细信息?

In SQL SERVER how can I get a list of all table names, column names and owners? I have done this but where do I get the OWNER details?

SELECT t.name AS tableName, s.name SchemaName FROM sys.tables AS t INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id]

推荐答案

请注意,"TABLE_OWNER"与"SCHEMA Owner"相同,并且"TABLE_TYPE"将标识该项目是否为表或视图.

Note that "TABLE_OWNER" is that same as "SCHEMA Owner" and "TABLE_TYPE" will identify if the item is a table OR view.

希望这会有所帮助!

--This will return all tables, table owners and table types for all database(s) that are NOT 'Offline' --Offline database information will not appear Declare @temp_table table( DB_NAME varchar(max), TABLE_OWNER varchar(max), TABLE_NAME varchar(max), TABLE_TYPE varchar(max), REMARKS varchar(max) ) INSERT INTO @temp_table (DB_NAME, TABLE_OWNER, TABLE_NAME, TABLE_TYPE,REMARKS) EXECUTE master.sys.sp_MSforeachdb 'USE [?]; EXEC sp_tables' SELECT * FROM @temp_table --Uncomment below if you are seaching for 1 database --WHERE DB_NAME = '<Enter specific DB Name>' --For all databases other than 'System Databases' WHERE DB_NAME not in ('master','model','msdn','tempdb') order by 1

更多推荐

列出表名称,所有者,架构和SQL Server数据库中的列

本文发布于:2023-10-16 05:34:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496646.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所有者   数据库中   架构   名称   Server

发布评论

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

>www.elefans.com

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