MYSQL 數據庫名、表名、字段名查詢


 //查詢所有表的所有字段:

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

 效果:

 

//查詢指定表的所有字段:

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

效果:

 //查詢指定表的所有字段的指定類型,注釋:

查詢所有含有此字段名的表:

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

查詢指定數據庫含有此字段名的表:

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

 

查詢指定表數據庫指定表的所有字段

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

查詢指定表數據庫指定表的第二個字段名:

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

以上,舉一反三

---------------------完畢----------------------------

 

 

-----------------------------------------------------------------------------

 

 

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM