国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

如何獲取SqlServer2005表結構(字段,主鍵,外鍵,遞增,描述)

2024-07-24 13:01:32
字體:
來源:轉載
供稿:網友
1.獲取表的基本字段屬性

復制代碼 代碼如下:


--獲取SqlServer中表結構
SELECT syscolumns.name,systypes.name,syscolumns.isnullable,
syscolumns.length
FROM syscolumns, systypes
WHERE syscolumns.xusertype = systypes.xusertype
AND syscolumns.id = object_id('你的表名')


運行效果

如何獲取SqlServer2005表結構(字段,主鍵,外鍵,遞增,描述)

2.如果還想要獲取字段的描述信息則

復制代碼 代碼如下:


--獲取SqlServer中表結構 主鍵,及描述
declare @table_name as varchar(max)
set @table_name = '你的表名'
select sys.columns.name, sys.types.name, sys.columns.max_length, sys.columns.is_nullable,
(select count(*) from sys.identity_columns where sys.identity_columns.object_id = sys.columns.object_id and sys.columns.column_id = sys.identity_columns.column_id) as is_identity ,
(select value from sys.extended_properties where sys.extended_properties.major_id = sys.columns.object_id and sys.extended_properties.minor_id = sys.columns.column_id) as description
from sys.columns, sys.tables, sys.types where sys.columns.object_id = sys.tables.object_id and sys.columns.system_type_id=sys.types.system_type_id and sys.tables.name=@table_name order by sys.columns.column_id


運行效果

如何獲取SqlServer2005表結構(字段,主鍵,外鍵,遞增,描述)


3.單獨查詢表的遞增字段

復制代碼 代碼如下:


--單獨查詢表遞增字段
select [name] from syscolumns where
id=object_id(N'你的表名') and COLUMNPROPERTY(id,name,'IsIdentity')=1


運行效果


4.獲取表的主外鍵

復制代碼 代碼如下:


--獲取表主外鍵約束
exec sp_helpconstraint '你的表名' ;


運行效果

如何獲取SqlServer2005表結構(字段,主鍵,外鍵,遞增,描述)



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 区。| 彭山县| 普格县| 阳谷县| 高青县| 深州市| 罗江县| 昆山市| 华阴市| 武山县| 平定县| 琼海市| 紫阳县| 牙克石市| 皮山县| 青岛市| 汨罗市| 云浮市| 花莲市| 伽师县| 阳江市| 鄢陵县| 海城市| 正定县| 阿克苏市| 山丹县| 财经| 韩城市| 塘沽区| 许昌县| 高清| 望江县| 宜黄县| 灌云县| 广水市| 白玉县| 昆山市| 旬阳县| 邹城市| 永清县| 射阳县|