如何查询数据库中全部表格,或者查询是否存在某个表格-mysql和oracle

这个问题,在以前就有写过,可是想找到语句仍是记不得,这里主要说起我本身有用到的数据库mysql和oraclemysql

一、mysqlsql

  这个是本身安装的,全部配置都是默认配置没有改变,因此保存表名的表仍是information_schema.tables,语句以下:数据库

--获取数据库中全部用户名,表名
select table_schema 用户名,table_name 表名 from information_schema.tables --获取'test'用户下全部表
select table_schema 用户名,table_name 表名 from information_schema.tables where table_schema='test'
--判断'test'用户下是否有'user'表
select * 
from information_schema.tables where table_schema='test'
  and table_name='user' 
--在mysql里面表名、用户名能够不区分大小写,譬以下面语句也能够查询出结果
select * 
from information_schema.tables where table_schema='TEST'
  and table_name='uSer'

二、Oracleoracle

  这个不是个人数据库,而oralce中保存表名的表在网上也是众说纷纭,我最终找到的表是all_tables,并且它保存的表名做为字符串是区分大小写的spa

--取某个表
select * from all_tables WHERE upper(OWNER) LIKE '用户名大写' AND upper(TABLE_NAME) LIKE '表名大写'
--取库中全部表
select * from all_tables select * from all_tables@想要的远程库
相关文章
相关标签/搜索