資料字典的匯出sql語句

2021-10-09 12:10:39 字數 1503 閱讀 7438

select

c.table_name 表明,

t.table_comment 表備註,

c.column_name 列名,

c.column_type 資料型別,

c.data_type 字段型別,

c.character_maximum_length 長度,

c.is_nullable 是否為空,

c.column_default 預設值,

c.column_comment 備註

from

information_schema.columns c

left join information_schema.tables t on c.table_name = t.table_name

where

c.table_schema = '庫的名字'

-- and c.table_name = '表明'

and c.table_name like '表明'

information_schema這張資料表儲存了mysql伺服器所有資料庫的資訊。如資料庫名,資料庫的表,表欄的資料型別與訪問許可權等。

再簡單點,這台mysql伺服器上,到底有哪些資料庫、各個資料庫有哪些表,每張表的字段型別是什麼,各個資料庫要什麼許可權才能訪問,等等資訊都儲存在information_schema表裡面。

mysql的information_schema資料庫包含了一些表和檢視,提供了訪問資料庫元資料的方式。

元資料是關於資料的資料,如資料庫名或表名,列的資料型別,或訪問許可權等。有些時候用於表述該資訊的其他術語包括「資料詞典」和「系統目錄」。

下面對一些重要的資料字典表做一些說明:

schemata表:提供了關於資料庫的資訊。

tables表:給出了關於資料庫中的表的資訊。

columns表:給出了表中的列資訊。

statistics表:給出了關於表索引的資訊。

user_privileges表:給出了關於全程許可權的資訊。該資訊源自mysql.user授權表。

schema_privileges表:給出了關於方案(資料庫)許可權的資訊。該資訊來自mysql.db授權表。

table_privileges表:給出了關於表許可權的資訊。該資訊源自mysql.tables_priv授權表。

column_privileges表:給出了關於列許可權的資訊。該資訊源自mysql.columns_priv授權表。

character_sets表:提供了關於可用字符集的資訊。

collations表:提供了關於各字符集的對照資訊。

table_constraints表:描述了存在約束的表。

key_column_usage表:描述了具有約束的鍵列。

routines表:提供了關於儲存子程式(儲存程式和函式)的資訊。此時,routines表不包含自定義函式(udf)。

views表:給出了關於資料庫中的檢視的資訊。

triggers表:提供了關於觸發程式的資訊。

SQL 匯出資料字典

用於參考 select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,主鍵 case ...

SQL資料字典

set ansi nulls on set quoted identifier on goalter procedure dbo proc dataselect tabelname varchar 100 asselect tablename o.name,fieldid c.colid,field...

mysql 匯出資料字典

select table catalog,table schema as 資料庫名,table name as 表名,column name as 欄位名,ordinal position as 字段位置,column default as 字段預設值,is nullable 是否允許空值,data...