如何獲得mysql資料庫的所有的列

2021-07-06 03:13:58 字數 658 閱讀 6808



應用場景:

1、封裝jdbc 時,獲取 某一張表 table 的所有字段(列)

2、報表開發 時,對錶進行操作

查詢資料庫中所有表名

select  table_name 

from `information_schema`.`tables`

where `table_schema`='資料庫名稱'

and `table_type`='base table';

獲得mysql資料庫的所有的列

select  column_name 

from `information_schema`.`columns`

where`table_name`='表名'

order by column_name;

所有字段獲取:

select column_name 

from `information_schema`.`columns`

where `table_schema`='資料庫名稱'

and `table_name`='表名'

order by column_name;

如何獲得資料庫裡所有表的名字

平時我們操作比較多的都是表裡的資料,也許突然有一天會需要把所有表的名字都列出來看一看 比如,你的論壇是按每個版塊乙個表來管理的,這時候你要在首頁列出各版塊的名字。應該怎麼辦呢?肯定得用select吧 但我們平時使用select操作的資料都是表裡的資料,表的名字並不是表的資料,這可怎麼辦呢?你可能會想...

獲得資料庫中所有的表

在資料庫中一般都會有乙個系統表來記錄下所有的使用者表或檢視,儲存過程等等的.名字就叫sysobjects.所有要查詢出所有的表可以用以下語句 sql2000 select from sysobjects where xtype u或 v 或 p access select from msysobje...

如何獲取Mysql資料庫中所有表名

歡迎加入bim行業開發交流1群 群號 711844216 小夥伴們在使用資料庫時,有時候不止需要訪問其中的乙個表,而是多個表,這個時候就需要首先獲取資料庫中的表名,然後迴圈讀取表了。sql語句 show tables from 資料庫名 using system using system.colle...