復(fù)制代碼 代碼如下:
CREATE VIEW dbo.vw_db_dictionary
AS
SELECT TOP 100 PERCENT dbo.sysobjects.name AS table_name,
dbo.sysproperties.[value] AS table_desc, dbo.syscolumns.name AS field,
properties.[value] AS field_desc, dbo.systypes.name AS field_type,
dbo.syscolumns.length AS field_size,
ISNULL(COLUMNPROPERTY(dbo.syscolumns.id, dbo.syscolumns.name, 'Scale'), 0)
AS field_precision, dbo.syscolumns.isnullable AS nullable,
CASE WHEN syscomments.text IS NULL
THEN '' ELSE syscomments.text END AS default_value,
CASE WHEN COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'IsIdentity')
= 1 THEN '√' ELSE '' END AS is_identity, CASE WHEN EXISTS
(SELECT 1
FROM sysobjects
WHERE xtype = 'PK' AND name IN
(SELECT name
FROM sysindexes
WHERE indid IN
(SELECT indid
FROM sysindexkeys
WHERE id = syscolumns.id AND colid = syscolumns.colid)))
THEN '√' ELSE '' END AS is_key
FROM dbo.syscolumns INNER JOIN
dbo.sysobjects ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype LEFT OUTER JOIN
dbo.sysproperties properties ON dbo.syscolumns.id = properties.id AND
dbo.syscolumns.colid = properties.smallid LEFT OUTER JOIN
dbo.sysproperties ON dbo.sysobjects.id = dbo.sysproperties.id AND
dbo.sysproperties.smallid = 0 LEFT OUTER JOIN
dbo.syscomments ON dbo.syscolumns.cdefault = dbo.syscomments.id
WHERE (dbo.sysobjects.xtype = 'U')
ORDER BY dbo.sysobjects.name
您可能感興趣的文章:- 講解Oracle數(shù)據(jù)庫中的數(shù)據(jù)字典及相關(guān)SQL查詢用法
- js實(shí)現(xiàn)的類似于asp數(shù)據(jù)字典的數(shù)據(jù)類型代碼實(shí)例
- mssql2005,2008導(dǎo)出數(shù)據(jù)字典實(shí)現(xiàn)方法
- Oracle的數(shù)據(jù)字典技術(shù)簡(jiǎn)析
- windows下apache+php+mysql 環(huán)境配置方法
- linux下安裝apache與php;Apache+PHP+MySQL配置攻略
- PHP讀取MySQL數(shù)據(jù)代碼
- CentOS 6.4安裝配置LAMP服務(wù)器(Apache+PHP5+MySQL)
- CentOS+Nginx+PHP+MySQL詳細(xì)配置(圖解)
- php生成mysql的數(shù)據(jù)字典