zoukankan      html  css  js  c++  java
  • 如何查询数据库中所有表格,或者查询是否存在某个表格-mysql和oracle

    这个问题,在之前就有写过,但是想找到语句还是记不得,这里主要提及我自己有用到的数据库mysql和oracle

    1、mysql

      这个是自己安装的,所有配置都是默认配置没有改变,所以保存表名的表还是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'

    2、Oracle

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

    --取某个表
    select * from all_tables WHERE upper(OWNER) LIKE '用户名大写' AND upper(TABLE_NAME) LIKE '表名大写'
    --取库中所有表
    select * from all_tables
    select * from all_tables@想要的远程库

      

    当你深入了解,你就会发现世界如此广袤,而你对世界的了解则是如此浅薄,请永远保持谦卑的态度。
  • 相关阅读:
    C++标准库之泛型算法
    auto 和 decltype (C++11 新增)
    C++ primer学习记录(个人猜想未测试版本)
    linux学习笔记之文件类型,及目录介绍
    crontab指令详解
    linux学习笔记之硬盘分区
    内存知识整理。
    JSON格式
    DuiLib(四)——控件绘制
    DuiLib(三)——控件消息
  • 原文地址:https://www.cnblogs.com/liwxmyself/p/12066262.html
Copyright © 2011-2022 走看看