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@想要的远程库

      

    当你深入了解,你就会发现世界如此广袤,而你对世界的了解则是如此浅薄,请永远保持谦卑的态度。
  • 相关阅读:
    Web前端之jQuery 的10大操作技巧
    Python开发者须知 —— Bottle框架常见的几个坑
    string、const char*、 char* 、char[]相互转换
    SLAM中的变换(旋转与位移)表示方法
    SLAM
    二叉搜索树(BST)
    Linux下OSG的编译和安装以及遇到的问题
    CMake--Set用法
    CMake--List用法
    php面向对象面试题
  • 原文地址:https://www.cnblogs.com/liwxmyself/p/12066262.html
Copyright © 2011-2022 走看看