记录一些有用的SQL

https://www.cnblogs.com/Alwaysbecoding/p/6959262.html
//查询所有表的所有字段:
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

posted @ 2023-05-08 16:20  知冷知热  阅读(21)  评论(0)    收藏  举报