MySQL獲取表的部分描述

2021-07-28 05:55:40 字數 1082 閱讀 8148

專案要求寫資料庫設計說明文件,其中要求的描述字段如下:

字段

型別

null

key

預設

注釋

main_line_require_id

bigint(16)

yes主線路需求id

date

datetime

yes日期

business_mode

varchar(30)

yes運營模式

create_tm

datetime

yes建立時間

tidbigint(16)

nopri

自增列require_id

bigint(16)

yes子需求id

用表的描述語句:desc 

最後一列指是否自增,而非備註。select

column_name as '列名',

data_type as '資料型別',

column_key as '主鍵',

is_nullable as '是否允許非空',

column_default as '預設值',

column_comment as '備註'

from

information_schema. columns t

where

table_name = 'tt_rs_plan_line_feedback';

查詢結果:

獲取表描述資訊

create view v table des asselect表名 o.name,表描述 ptb.value 字段序號 c.column id,欄位名 c.name,字段描述 isnull pfd.value n 主鍵 isnull idx.primarykey,0 可空 c.is nullabl...

Mysql 獲取表資訊 獲取表詳情

查詢資料庫表結構 select table schema as 資料庫名 table name as 資料表名 create time as 建立時間 table comment as 描述 from information schema.tables where table schema 資料庫名...

MySQL獲取錶行數

1.獲取單錶的行數select count from table name 2.獲取多表的行數 可以使用 union 運算子組合每個select語句返回的結果集 select tablename1 tablename,count rows from table name1 union select ...