概述
今天主要介紹SQLServer數(shù)據(jù)庫如何快速查看表結(jié)構(gòu)和獲取相關(guān)信息。僅供參考。
全面查看表結(jié)構(gòu)sql
SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名, col.colorder AS 序號 , col.name AS 列名 , ISNULL(ep.[value], '') AS 列說明 , t.name AS 數(shù)據(jù)類型 , col.length AS 長度 , ISNULL(COLUMNPROPERTY, col.name, 'Scale'), 0) AS 小數(shù)位數(shù) , CASE WHEN COLUMNPROPERTY, col.name, 'IsIdentity') = 1 THEN '√' ELSE '' END AS 標(biāo)識 , CASE WHEN EXISTS ( SELECT 1 FROM dbo.sysindexes si INNER JOIN dbo.sysindexkeys sik ON = AND = INNER JOIN dbo.syscolumns sc ON = AND = INNER JOIN dbo.sysobjects so ON = AND = 'PK' WHERE = col.id AND = col.colid ) THEN '√' ELSE '' END AS 主鍵 , CASE WHEN col.isnullable = 1 THEN '√' ELSE '' END AS 允許空 , ISNULL, '') AS 默認(rèn)值 FROM dbo.syscolumns col LEFT JOIN dbo.systypes t ON col.xtype = t.xusertype inner JOIN dbo.sysobjects obj ON col.id = obj.id AND obj.xtype = 'U' AND obj.status >= 0 LEFT JOIN dbo.syscomments comm ON col.cdefault = comm.id LEFT JOIN ep ON col.id = ep.major_id AND col.colid = ep.minor_id AND ep.name = 'MS_Description' LEFT JOIN epTwo ON obj.id = e AND e = 0 AND e = 'MS_Description' WHERE obj.name in ('表名') -- 表名 ORDER BY col.colorder;
后面會分享更多devops和DBA方面問題,感興趣的朋友可以關(guān)注下!
1.《關(guān)于sql怎么快速查詢,你需要知道這些分享sqlserver數(shù)據(jù)庫如何快速查看表結(jié)構(gòu)sql》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識,僅代表作者本人觀點(diǎn),與本網(wǎng)站無關(guān),侵刪請聯(lián)系頁腳下方聯(lián)系方式。
2.《關(guān)于sql怎么快速查詢,你需要知道這些分享sqlserver數(shù)據(jù)庫如何快速查看表結(jié)構(gòu)sql》僅供讀者參考,本網(wǎng)站未對該內(nèi)容進(jìn)行證實,對其原創(chuàng)性、真實性、完整性、及時性不作任何保證。
3.文章轉(zhuǎn)載時請保留本站內(nèi)容來源地址,http://f99ss.com/gl/3109971.html