ZengJiaLin

写在前面


在实现某个功能的时候,需要使用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

分类:

技术点:

相关文章: