oracle sql-大全
2013-12-19 09:59
399 查看
select * from user_tab_comments; --查询表注释
select table_name,column_name,comments from user_col_comments where table_name=upper('pay_bindbank') --查询表详情
1、查询出所有的用户表
select * from user_tables 可以查询出所有的用户表
通过表名过滤需要将字母作如下处理
select * from user_tables where table_name = upper('表名')
因为无论你建立表的时候表名名字是大写还是小写的,create语句执行通过之后,对应的user_tables表中的table_name字段都会自动变为大写字母,所以必须通过内置函数upper将字符串转化为大写字母进行查询,否则,即使建表语句执行通过之后,通过上面的查询语句仍然查询不到对应的记录。
2、查询出用户所有表的索引
select * from user_indexes
3、查询用户表的索引(非聚集索引):
select * from user_indexes where uniqueness='NONUNIQUE'
4、查询用户表的主键(聚集索引):
select * from user_indexes where uniqueness='UNIQUE'
5、查询表的索引
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and
t.table_name='NODE'
6、查询表的主键
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and
au.constraint_type = 'P' AND cu.table_name = 'NODE'
7、查找表的唯一性约束(包括名称,构成列):
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name=au.constraint_name and
cu.table_name='NODE'
8、查找表的外键
select * from user_constraints c where c.constraint_type = 'R' and c.table_name='STAFFPOSITION'
查询外键约束的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键名称
查询引用表的键的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名
9、查询表的所有列及其属性
方法一:
select * from user_tab_columns where table_name=upper('表名');
方法二:
select cname,coltype,width from col where tname=upper('表名');
select table_name,column_name,comments from user_col_comments where table_name=upper('pay_bindbank') --查询表详情
1、查询出所有的用户表
select * from user_tables 可以查询出所有的用户表
通过表名过滤需要将字母作如下处理
select * from user_tables where table_name = upper('表名')
因为无论你建立表的时候表名名字是大写还是小写的,create语句执行通过之后,对应的user_tables表中的table_name字段都会自动变为大写字母,所以必须通过内置函数upper将字符串转化为大写字母进行查询,否则,即使建表语句执行通过之后,通过上面的查询语句仍然查询不到对应的记录。
2、查询出用户所有表的索引
select * from user_indexes
3、查询用户表的索引(非聚集索引):
select * from user_indexes where uniqueness='NONUNIQUE'
4、查询用户表的主键(聚集索引):
select * from user_indexes where uniqueness='UNIQUE'
5、查询表的索引
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and
t.table_name='NODE'
6、查询表的主键
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and
au.constraint_type = 'P' AND cu.table_name = 'NODE'
7、查找表的唯一性约束(包括名称,构成列):
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name=au.constraint_name and
cu.table_name='NODE'
8、查找表的外键
select * from user_constraints c where c.constraint_type = 'R' and c.table_name='STAFFPOSITION'
查询外键约束的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键名称
查询引用表的键的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名
9、查询表的所有列及其属性
方法一:
select * from user_tab_columns where table_name=upper('表名');
方法二:
select cname,coltype,width from col where tname=upper('表名');
相关文章推荐
- Oracle SQL 内置函数大全
- SQL语句大全-程序员必备(Oracle版)
- Oracle SQL 内置函数大全(4)
- Oracle PL/SQL 编程手册(SQL大全)
- oracle sql plus 命令大全
- Oracle PL/SQL 编程手册(SQL大全)(转)
- Oracle SQL 内置函数大全()
- oracle中sql*plus命令大全
- Oracle SQL语句大全(一)
- Oracle SQL 内置函数大全
- oracle SQL命令大全
- Oracle导入SQL脚本执行和常用命令大全
- oracle pl/SQL函数大全(1)
- Oracle的SQL*PLUS命令的使用大全
- oracle_sql语句的大全
- Oracle SQL 内置函数大全
- Oracle SQL 內置函數大全
- Oracle 10g的使用【SQLPLUS操作大全】
- oracle sqlplus 常用命令大全
- oracle sqlplus 常用命令大全