文章摘要
这篇文章展示了如何使用SQL语言从`information_schema`表中提取表结构和列名信息。通过使用`SELECT`语句结合`CONCAT_WS`函数,作者将`information_schema.tables.table_schema`表的表结构与`information_schema.cOLUMNS`表的列名进行连接,形成一个统一的表结构。进一步使用`LEFT JOIN`关联两张表,并通过`WHERE`条件筛选出列名,最后使用`LIMIT 0,1`限制只返回一条记录。这一查询可以用于快速获取数据库表结构及列名的详细信息。
select concat_ws(0x2f,information_schema.tables.table_schema,`information_schema`.`COLUMNS`.table_name,`information_schema`.`COLUMNS`.column_name) from `information_schema`.`COLUMNS` left join information_schema.tables on `information_schema`.`COLUMNS`.table_name=information_schema.tables.table_name where `information_schema`.`COLUMNS`.column_name like 0x257061737325 limit 0,1;
© 版权声明
文章版权归作者所有,未经允许请勿转载。