在数据库表较多的时候,需要查看某个字段存在于哪几张表中:
例如:查询hrm的数据库中,部门代码DEPARTMENT_CODE涉及到哪几张表的代码:
select distinct TABLE_NAME from information_schema.`COLUMNS`
where COLUMN_NAME='DEPARTMENT_CODE' and TABLE_SCHEMA='hrm'
and TABLE_NAME not like 'vm%';
结果:
在数据库表较多的时候,需要查看某个字段存在于哪几张表中:
例如:查询hrm的数据库中,部门代码DEPARTMENT_CODE涉及到哪几张表的代码:
select distinct TABLE_NAME from information_schema.`COLUMNS`
where COLUMN_NAME='DEPARTMENT_CODE' and TABLE_SCHEMA='hrm'
and TABLE_NAME not like 'vm%';
结果: