博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle:查找表的主键,外键,唯一性约束,索引
阅读量:7111 次
发布时间:2019-06-28

本文共 1058 字,大约阅读时间需要 3 分钟。

hot3.png

1、查找表的所有索引(包括索引名,类型,构成列): 
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表 
2、查找表的主键(包括名称,构成列): 
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name = 要查询的表 
3、查找表的唯一性约束(包括名称,构成列): 
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'U' and au.table_name = 要查询的表 
4、查找表的外键(包括名称,引用表的表名和对应的键名,下面是分成多步查询): 
select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查询的表 
查询外键约束的列名: 
select * from user_cons_columns cl where cl.constraint_name = 外键名称 
查询引用表的键的列名: 
select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名 
5、查询表的所有列及其属性 
select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = 要查询的表 

转载于:https://my.oschina.net/yululaile/blog/55542

你可能感兴趣的文章
王垠:怎样写一个解释器
查看>>
解决unicodedecodeerror ascii codec can’t decode byte 0xd7 in position 9 ordinal not in range(128)...
查看>>
Redis和Memcached的区别
查看>>
CSS选择器种类及介绍
查看>>
struts2 + form 表单上传文件
查看>>
Centos7下安装mongodb
查看>>
ES架构及原理
查看>>
Windows7 自动更新时遇到故障
查看>>
我的友情链接
查看>>
spring加载配置属性文件(properties)
查看>>
redis设置
查看>>
android的唯一性
查看>>
深入理解java虚拟机——OutOfMemoryError异常
查看>>
《The way to go》中文版
查看>>
jQuery设置元素是否显示
查看>>
samsung Galaxy S3 i9300 获得root权限
查看>>
.NET EasyUI datebox添加清空功能
查看>>
查看Android手机保存的WIFI无线密码
查看>>
Linux系统生成随机密码的10种方法
查看>>
湖南省委短信平台改造方案
查看>>