mysql查詢所有表和字段信息的方法:1、根據(jù)庫名獲取所有表的信息【information_schema.`tables`】;2、根據(jù)庫名獲取所有的字段信息【ordinal_position as '列的排列順序'】。
mysql查詢所有表和字段信息的方法:
1、根據(jù)庫名獲取所有表的信息
select *from information_schema.`tables`where table_schema = 'erp';2、根據(jù)庫名獲取所有表名稱和表說明
select table_name, table_commentfrom information_schema.`tables`where table_schema = 'erp';view:
3、根據(jù)庫名獲取所有的字段信息
select table_schema as '庫名', table_name as '表名', column_name as '列名', ordinal_position as '列的排列順序', column_default as '默認值', is_nullable as '是否為空', data_type as '數(shù)據(jù)類型', character_maximum_length as '字符最大長度', numeric_precision as '數(shù)值精度(最大位數(shù))', numeric_scale as '小數(shù)精度', column_type as 列類型, column_key 'key', extra as '額外說明', column_comment as '注釋'from information_schema.`columns`where table_schema = 'erp'order by table_name, ordinal_position;view:
4、根據(jù)庫名獲取所有的庫和表字段的基本信息
select c.table_schema as '庫名', t.table_name as '表名', t.table_comment as '表注釋', c.column_name as '列名', c.column_comment as '列注釋', c.ordinal_position as '列的排列順序', c.column_default as '默認值', c.is_nullable as '是否為空', c.data_type as '數(shù)據(jù)類型', c.character_maximum_length as '字符最大長度', c.numeric_precision as '數(shù)值精度(最大位數(shù))', c.numeric_scale as '小數(shù)精度', c.column_type as 列類型, c.column_key 'key', c.extra as '額外說明'from information_schema.`tables` tleft join information_schema.`columns` c on t.table_name = c.table_nameand t.table_schema = c.table_schemawhere t.table_schema = 'erp' order by c.table_name, c.ordinal_position;view:
更多相關(guān)免費學(xué)習(xí)推薦:mysql教程(視頻)