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

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;

最新文章

  1. C++中输入输出的重定向
  2. CreateCompatibleDC与CreateCompatibleBitmap
  3. 《Apache数据传输加密、证书的制作》——涉及HTTPS协议
  4. Java Web开发 之小张老师总结中文乱码解决方案
  5. posix和system v有什么区别/?
  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
  7. 在新浪sae上部署WeRoBot
  8. macOS 中 apache vhosts 配置备忘
  9. Linux进程管理:后台启动进程和任务管理命令
  10. phantomjs 了解
  11. Spring IOC 低级容器解析
  12. stop 用法
  13. NodeJS + React + Webpack + Echarts
  14. 每天学一点儿HTML5的新标签
  15. Linux RPM和YUM
  16. mac date 和 Linux date实现从指定时间开始循环
  17. NetCore2.0 RozarPage自动生成增删改查
  18. 用squid配置代理服务器(基于Ubuntu Server 12.04)
  19. php去除html
  20. Cent OS安装My Sql

热门文章

  1. shell报错:未预期的符号***附近有语法错误
  2. linux的chmod命令
  3. C#文本之XML
  4. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-人机界面如何设置页面跳转
  5. python abstractmethod 对象比较
  6. python基础语法(四)
  7. AND、OR运算符的组合使用
  8. android 调用系统界面
  9. python challenge - map.py
  10. C语言-编译