當前位置:
首頁 > 知識 > MYSQL 資料庫名、表名、欄位名查詢

MYSQL 資料庫名、表名、欄位名查詢

//查詢所有表的所有欄位:

select * from information_schema.columns where table_name="sys_users"

效果:

MYSQL 資料庫名、表名、欄位名查詢

//查詢指定表的所有欄位:

select * from information_schema.columns where table_name="sys_users" and TABLE_SCHEMA="taoke"

效果:

MYSQL 資料庫名、表名、欄位名查詢

//查詢指定表的所有欄位的指定類型,注釋:

MYSQL 資料庫名、表名、欄位名查詢

查詢所有含有此欄位名的表:

SELECT * FROM information_schema.columns WHERE column_name="name";

MYSQL 資料庫名、表名、欄位名查詢

查詢指定資料庫含有此欄位名的表:

SELECT * FROM information_schema.columns WHERE column_name="name" and TABLE_SCHEMA="wljdb";

MYSQL 資料庫名、表名、欄位名查詢

查詢指定表資料庫指定表的所有欄位

select column_name from information_schema.COLUMNS where table_name="sys_users" and TABLE_SCHEMA="taoke"

MYSQL 資料庫名、表名、欄位名查詢

查詢指定表資料庫指定表的第二個欄位名:

select column_name from information_schema.COLUMNS where table_name="sys_users" and TABLE_SCHEMA="taoke" LIMIT 1,1

MYSQL 資料庫名、表名、欄位名查詢

以上,舉一反三

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 程序員小新人學習 的精彩文章:

AudioManager(音頻管理器)
記錄一次壯烈犧牲的阿里巴巴面試!

TAG:程序員小新人學習 |