zoukankan      html  css  js  c++  java
  • MySQL中 如何查询表名中包含某字段的表

    查询tablename 数据库中 以"_copy" 结尾的表

    select table_name from information_schema.tables where table_schema='tablename' and table_type='base table' and table_name like '%_copy';

    information_schema 是MySQL系统自带的数据库,提供了对数据库元数据的访问
    information_schema.tables 指数据库中的表(information_schema.columns 指列)
    table_schema 指数据库的名称
    table_type 指是表的类型(base table 指基本表,不包含系统表)
    table_name 指具体的表名

    查询work_ad数据库中是否存在包含"user"关键字的数据表

     select table_name from information_schema.tables where table_schema = 'work_ad' and table_type='base table' and table_name like '%user%';

    如果本身是在tablename 这个库里新建的查询,可以去掉 table_schema='tablename ' 这一句
    select table_name from information_schema.tables where table_type='base table' and table_name like '%_copy';

    在Informix数据库中,如何查询表名中包含某字段的表

    select * from systables where tabname like 'saa%'

    此法只对Informix数据库有用

    查询指定数据库中指定表的所有字段名column_name

    select column_name from information_schema.columns where table_schema='csdb' and table_name='xxx'

     检查数据库'test'中的某一个表'd_ad'是否存在

    select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad';

    如何查询mysql数据库中有多少张表

    select count(*) TABLES, table_schema from information_schema.tables where table_schema = 'test' group by table_schema;

    mysql中查询到包含该字段的所有表名

    SELECT  TABLE_NAME FROM  information_schema.COLUMNS  WHERE  COLUMN_NAME='字段名'

    如:查询包含status 字段的数据表名

    select table_name from information_schema.columns where column_name='status';
  • 相关阅读:
    vim——打开多个文件、同时显示多个文件、在文件之间切换(转)
    内核任务调度与数据结构
    chrome浏览器iframe兼容性问题,隐藏起来再显示滚动条消失?
    九、迭代器、生成器、函数递归调用与二分法
    八、函数、闭包、装饰器
    七、函数
    六、字符编码、文件
    五、列表、元组、字典、集合详解
    四、字符串及其内置方法
    三、内存管理、数据类型、基本运算符、流程控制
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15453184.html
Copyright © 2011-2022 走看看