zoukankan      html  css  js  c++  java
  • SQL.Cookbook 读书笔记5 元数据查询

    第五章 元数据查询 查询数据库本身信息 表结构 索引等

    5.1 查询test库下的所有表信息

    MYSQL

    SELECT * from information_schema.`TABLES` WHERE TABLE_SCHEMA = 'test';

    ORACLE

    select table_name from all_tables where owner = 'test';

    5.2 查询表中列的信息

    MYSQL

    SELECT * from information_schema.`COLUMNS` WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'student';

    ORACLE

    select * from all_tab_columns where owner = 'test' and table_name = 'student';

    5.3 列出表的索引

    MYSQL

    show index from emp;

    ORACLE

    select table_name,index_name,column_name,column_position from sys.all_ind_columns where table_name = 'emp' and table_owner = 'test';

    5.4 列出表约束

    ORACLE

    select a.table_name,a.constraint_name,b.coulumn_name,a.constraint_type from all_constraints a,all_cons_columns b where a.table_name = 'EMP' and a.owner = 'test' and a.table_name = b.table_name and a. owner = b.owner and a.constraint_name = b.constraint_name;

    MYSQL

    select a.table_name,a.constraint_name,b.coulumn_name,a.constraint_type from information_schema.table_constraints a,information_schema.key_column_usage b where a.table_name = 'EMP' and a.table_schema= 'test' and a.table_name = b.table_name and a. table_schema = b.table_schema and a.constraint_name = b.constraint_name;

     5.5 显示表结构

    desc user;
  • 相关阅读:
    Java精选笔记_EL表达式
    Java精选笔记_文件上传与下载
    Java精选笔记_Servlet事件监听器
    windows 下安装perl Tk 模块
    html 基础
    用grep 筛选fastq 序列
    php 统计fasta 序列长度和GC含量
    perl 截取 fastq文件
    Java_基础知识回顾
    Git_期末总结
  • 原文地址:https://www.cnblogs.com/weixiaole/p/4252112.html
Copyright © 2011-2022 走看看