Abstract: MySQLinformation_schema库的使用

1
SELECT schema_name FROM information_schema.schemata;

OUT

显示出所有库名。

1
SELECT table_name FROM information_schema.tables WHERE table_schema='mynews';

OUT

显示出mynews库中所有表名。

1
SELECT table_name FROM information_schema.tables WHERE table_schema='test';

OUT

找到目标,发现test库中有两张表contentusers

1
SELECT column_name FROM information_schema.columns WHERE table_name='users';

显示出users表中的字段。

1
SELECT username, passwd FROM test.users;

OUT

1
SELECT column_name FROM information_schema.columns WHERE table_name='content';

显示出content表中的字段。

OUT