获得当前登录用户的所有数据库及对应的表

在mysql 下:


//查询当前登录用户下的所有数据库
select SCHEMA_NAME from information_schema.SCHEMATA
//根据数据库名查询对应的表
SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES   WHERE table_schema = '数据库' GROUP BY table_schema;



在sqlserver下:

select name from sys.databases --返回数据库名

select name from sys.tables --返回表名
select table_name from INFORMATION_SCHEMA.tables --返回表名

select name from sys.tables where type='u'--返回非系统表名



在oracle下:

//查询所有用户创建的表
select * from user_tables

//查询某个数据库下的所有表
select * from sys.all_tables where owner = 'QIAQIA'

你可能感兴趣的:(oracle,mysql)