小編給大家分享一下MySQL怎樣查詢所有表和字段信息,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、網(wǎng)站空間、營銷軟件、網(wǎng)站建設(shè)、鐵山港網(wǎng)站維護(hù)、網(wǎng)站推廣。
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_COMMENT FROM 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 '默認(rèn)值', 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 '默認(rèn)值', 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` T LEFT JOIN information_schema.`COLUMNS` C ON T.TABLE_NAME = C.TABLE_NAME AND T.TABLE_SCHEMA = C.TABLE_SCHEMA WHERE T.TABLE_SCHEMA = 'erp' ORDER BY C.TABLE_NAME, C.ORDINAL_POSITION;
view:
看完了這篇文章,相信你對(duì)mysql怎樣查詢所有表和字段信息有了一定的了解,想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!