我使用对象资源管理器中的过滤器表执行此操作但我想用查询执行此操作,当我执行查询时,返回所有具有dbo架构及其字段的表。
Returns from sys.tables
, use schema_id
to filter
SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']'
AS TableName
FROM sys.tables where SCHEMA_NAME(schema_id) = 'dbo'
To Include Views in Schema
SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']'
AS TableName
FROM sys.tables where SCHEMA_NAME(schema_id) = 'dbo'
UNION
SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']'
AS TableName
FROM sys.views where SCHEMA_NAME(schema_id) = 'dbo'
Are you trying to get this information?
SELECT * FROM sys.tables WHERE schema_id = 1
--SchemaId 1 is for 'dbo' schema
If you want columns as well, then try this.
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo'
获取所有表,模式,列和数据在数据库中使用以下查询。
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.