生成資料庫結構設計說明書的儲存過程

2021-08-23 13:23:25 字數 2282 閱讀 1333

資料表設計說明書一般格式如下:

表名序號標識主鍵欄位名型別占用位元組長度允許空值預設值字段說明

蒐集整理了乙個儲存過程可以直接匯出到csv再儲存xls.再拷貝到word中

這個儲存過程使用之後發現一點,以後設計資料庫表的時候一定要做好相關備註,就省去了在word中填加字段描述的麻煩。不過有些不安全的就是在資料庫被盜了後,一切原理都被別人知道了。所以註冊會員密碼要加密。註冊郵箱要不要還要考慮。

--生成資料庫結構設計說明書

select

表名=case when a.colorder=1 then d.name else '' end,

序號=a.colorder,

標識=case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end,

主鍵=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 = a.id and colid=a.colid

))) then '√' else '' end,

欄位名=a.name,

型別=b.name,

占用位元組數=a.length,

長度=columnproperty(a.id,a.name,'precision'),

允許空值=case when a.isnullable=1 then '√'else '' end,

預設值=isnull(e.text,''),

字段描述=isnull(g.[value],'')

from syscolumns a

left join systypes b on a.xtype=b.xusertype

inner join sysobjects d on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'

left join syscomments e on a.cdefault=e.id

left join sysproperties g on a.id=g.id and a.colid=g.smallid

left join sysproperties f on d.id=f.id and f.smallid=0

--where d.name='要查詢的表' --如果只查詢指定表,加上此條件

order by a.id,a.colorder

--如果word檔案中設計好了字段和字段描述可以用下面語句新增資料庫表中字段描述

execute sp_addextendedproperty 'ms_description', '自增id','user', 'dbo', 'table', 'user', 'column', 'id'

execute sp_addextendedproperty 'ms_description', '使用者名稱','user', 'dbo', 'table', 'user', 'column', 'username'

execute sp_addextendedproperty 'ms_description', '使用者密碼','user', 'dbo', 'table', 'user', 'column', 'password'

execute sp_addextendedproperty 'ms_description', '網路呢稱','user', 'dbo', 'table', 'user', 'column', 'nickname'

execute sp_addextendedproperty 'ms_description', '性別','user', 'dbo', 'table', 'user', 'column', '***'

execute sp_addextendedproperty 'ms_description', '位址','user', 'dbo', 'table', 'user', 'column', 'address'

execute sp_addextendedproperty 'ms_description', '**','user', 'dbo', 'table', 'user', 'column', 'tel'

execute sp_addextendedproperty 'ms_description', 'qq','user', 'dbo', 'table', 'user', 'column', 'qq'

生成資料庫結構設計說明書的儲存過程

資料表設計說明書一般格式如下 表名 序號 標識 主鍵 欄位名 型別 占用位元組 長度 允許空值 預設值 字段說明 蒐集整理了乙個儲存過程可以直接匯出到csv再儲存xls.再拷貝到word中 這個儲存過程使用之後發現一點,以後設計資料庫表的時候一定要做好相關備註,就省去了在word中填加字段描述的麻煩...

資料庫設計說明書

專案名稱 資料庫設計說明書 版本 1.0 文件編號 密 級 秘密編寫 編寫日期 x 年xx月xx日審核 審核日期 x 年xx月xx日批准 批准日期 x 年xx月xx日 修訂記錄 版本 章節名稱 修訂內容 修訂日期 修訂人批准人 目 錄 1.文件介紹 1 1.1 文件目的 1 1.2 文件範圍 1 1...

資料庫設計說明書

圖書共享平台 本學期我們軟體工程課定製的題目是 圖書共享平台 通過編寫此資料庫設計說明書,來對我們 設計的資料庫進行介紹,分析。資料庫庭院裡與應用教程 第三版 何玉潔等編著 2 外部設計 2.1 識別符號和狀態 本系統採用 mrcrosoft sever2008 為基本開發工具 資料庫名稱為book...