1.查找某个表属于哪个数据库

SELECT table_schema FROM information_schema.TABLES WHERE table_name = '表名字';

2.查找某个字段在哪个数据库和表中有使用到:

select table_schema,table_name from information_schema.columns where column_name = '字段名字'
  1. 员工表中查询平均工资大于5000的员工的最低和最高工资:
    select dept,min(money),max(money) from user_dept where money >5000 group by dept HAVING avg(money) >5000
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐