MySql 获取数据库的所有表名

写在前面


在实现某个功能的时候,需要使用MySql数据库获取某数据的所有的表名以及该表名的所有列名与列值。

根据数据库获取该数据库下所有的表名


select table_name from information_schema.tables where table_schema='数据库表名'

根据表名获取列名与列值


select ORDINAL_POSITION as Colorder,Column_Name as ColumnName,COLUMN_COMMENT as DeText
from information_schema.columns where table_schema = '数据库名称' and table_name = '表名' 
order by ORDINAL_POSITION asc

原文地址:https://www.cnblogs.com/ZengJiaLin/p/11653915.html