sql:Oracle11g 表,视图,存储过程结构查询
-- Oracle 11 G
--20160921 涂聚文再次修改
--Geovin Du
--GetTables
SELECT owner, object_name, created FROM all_objects WHERE (owner in ( select USERNAME from user_users )) AND object_type = 'TABLE' ORDER BY owner, object_name; ---GEOVIN
SELECT owner, object_name, created FROM all_objects WHERE (owner in ( select USERNAME from user_users )) AND object_type = 'TABLE' and owner='GEOVIN' ORDER BY owner, object_name; --GetTableColumns
--declare @owner varchar(200),@tablename varchar(200) select * from all_tab_columns; select cols.column_name,
cols.data_type,
cols.data_length,
cols.data_precision,
cols.data_scale,
cols.nullable,
cmts.comments,
cols.owner,
cmts.owner,
cols.table_name
from all_tab_columns cols,
all_col_comments cmts
where cols.owner = cmts.owner
and cols.table_name = cmts.table_name
and cols.column_name = cmts.column_name
and cols.owner= 'GEOVIN'
--and ROWNUM <= 10
order by column_id; --表结构
select cols.column_name,
cols.data_type,
cols.data_length,
cols.data_precision,
cols.data_scale,
cols.nullable,
cmts.comments
from all_tab_columns cols,
all_col_comments cmts
where
cols.owner = 'GEOVIN' --
and cols.table_name = 'EMPLOYEELIST'--
and cols.owner = cmts.owner
and cols.table_name = cmts.table_name
and cols.column_name = cmts.column_name
order by column_id; --GetViews
select v.owner, v.view_name, o.created
from all_views v,
all_objects o
where v.view_name = o.object_name
and o.object_type = 'VIEW'
and (v.owner in ( select USERNAME from user_users ))
order by v.owner, v.view_name; ---GetViewColumns
select cols.column_name,
cols.data_type,
cols.data_length,
cols.data_precision,
cols.data_scale,
cols.nullable,
cmts.comments
from all_tab_columns cols,
all_col_comments cmts
where
cols.owner = 'GEOVIN' --
and cols.table_name = 'v_EMPLOYEELIST'---
and cols.owner = cmts.owner
and cols.table_name = cmts.table_name
and cols.column_name = cmts.column_name
order by column_id;
----GetTablePrimaryKey
select
cols.constraint_name,
cols.column_name,
cols.position
from
all_constraints cons,
all_cons_columns cols
where
cons.OWNER = 'GEOVIN'
and cons.table_name = 'EMPLOYEELIST'
and cons.constraint_type='P'
and cols.owner = cons.owner
and cols.table_name = cons.table_name
and cols.constraint_name = cons.constraint_name
order by cons.constraint_name, cols.position; ---GetTableIndexes
select idx.owner, idx.uniqueness, con.constraint_type, idx.table_type, col.*
from all_ind_columns col,
all_indexes idx,
all_constraints con
where idx.table_owner = '{0}'
AND idx.table_name = '{1}'
AND idx.owner = col.index_owner
AND idx.index_name = col.index_name
AND idx.owner = con.owner (+)
AND idx.table_name = con.table_name(+)
AND idx.index_name = con.constraint_name(+); ---GetTableKeys 表的主键
select
cols.constraint_name,
cols.column_name,
cols.position,
r_cons.table_name related_table_name,
r_cols.column_name related_column_name
from
all_constraints cons,
all_cons_columns cols,
all_constraints r_cons,
all_cons_columns r_cols
where cons.OWNER = 'GEOVIN'
and cons.table_name = 'EMPLOYEELIST'
and cons.constraint_type='R'
and cols.owner = cons.owner
and cols.table_name = cons.table_name
and cols.constraint_name = cons.constraint_name
and r_cols.owner = cons.r_owner
and r_cols.constraint_name = cons.r_constraint_name
and r_cons.owner = r_cols.owner
and r_cons.table_name = r_cols.table_name
and r_cons.constraint_name = r_cols.constraint_name
order by cons.constraint_name, cols.position; ---GetViewText 视图脚本
select text
from all_views
where owner = 'GEOVIN'
and view_name = 'VIEW_BOOKADMINISTRATOR'; --GetCommands 存储过程,包
select methods.owner,
methods.package_name,
methods.object_name,
methods.overload,
ao.object_type,
ao.created,
ao.status,
ao.object_id
from
(select distinct owner, package_name, object_name, overload, object_id from ALL_ARGUMENTS
where (owner in ( select USERNAME from user_users ))
) methods,
all_objects ao
where ao.object_id = methods.object_id
order by methods.owner, methods.package_name, methods.object_name; ---GetCommandParameters 显示存储过程参数
select
ARGUMENT_NAME,
POSITION,
SEQUENCE,
DATA_LEVEL,
DATA_TYPE,
IN_OUT,
DATA_LENGTH,
DATA_PRECISION,
DATA_SCALE
from ALL_ARGUMENTS
where --object_ID=0
--and
object_name = 'PROCSELECTBOOKKINDLIST' --PROCSELECTBOOKKINDLIST
--and 2
order by position;
--
select * from ALL_ARGUMENTS
where --object_ID=0
--and
object_name = 'PROCSELECTBOOKKINDLIST' --PROCSELECTBOOKKINDLIST
--and 2
order by position; ---GetCommandText 显示存储过程脚本
desc user_source; select text from user_source
where name = 'PROCSELECTBOOKKINDLIST'
order by line; SELECT * FROM DBA_source; SELECT * FROM ALL_source; select * from all_objects; --OWNER='GEOVIN' and select * from (select dense_rank() over (order by object_id) as dr,b.* from all_objects b) x where dr<=15; --存储过程
select * from user_objects where object_type = 'PROCEDURE'; --http://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm
--Oracle / PLSQL: Retrieve primary key information
--GetPrimaryKeys
SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
AND cols.owner='GEOVIN'
ORDER BY cols.table_name, cols.position; ---
SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = 'BOOKKINDLIST'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
AND cons.owner='GEOVIN'
ORDER BY cols.table_name, cols.position;
sql:Oracle11g 表,视图,存储过程结构查询的更多相关文章
- sql:sql server,MySQL,PostgreSQL的表,视图,存储过程结构查询
sql server 2005: --SQL SERVER 2005 生成代码需要知道的SQL语句 use LibrarySystem --查询当前数据库所有表和其的主键字段,字段类型,长度,是否为空 ...
- sql:MySQL 6.7 表,视图,存储过程结构查询
#数据库MySQL 6.7 use sakila; #查询表名 show tables; # SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA. ...
- sql 判断 表 视图 存储过程 存在 然后 删除
sql 判断 函数 存储过程是否存在的方法 (2010-12-03 10:08:57) 转载▼ 下面为您介绍sql下用了判断各种资源是否存在的代码,需要的朋友可以参考下,希望对您学习sql的函 ...
- SQLServer2008/2012 删除所有表视图存储过程
SQLServer2008/2012 删除所有表视图存储过程 -------------------删除所有的表-------------------use xuwenbin111--/第1步**** ...
- sql server 表变量存储临时查询数据
对于使用sql server 编写存储过程或者类似的sql 查询的时候我们使用表变量进行临时数据的存储,可以方便我们进行下来的数据处理 表变量的使用类似如下: declare @userinfo ta ...
- oracle 表 视图 存储过程 序列 job
table 表 --delete table drop table Test1; -- Create table create table TEST1 ( ID NUMBER, T_N ...
- SQl 判断 表 视图 临时表等 是否存在
1.判断是否存在addOneArticle这个存储过程 if Exists(select name from sysobjects where NAME = 'addOneArticle' and t ...
- SQL 单表分页存储过程和单表多字段排序和任意字段分页存储过程
第一种:单表多字段排序分页存储过程 --支持单表多字段查询,多字段排序 create PROCEDURE [dbo].[UP_GetByPageFiledOrder] ( ), --表 ...
- (转)减少oracle sql回表次数 提高SQL查询性能
要写出高效的SQL,那么必须必须得清楚SQL执行路径,介绍如何提高SQL性能的文章很多,这里不再赘述,本人来谈谈如何从 减少SQL回表次数 来提高查询性能,因为回表将导致扫描更多的数据块. 我们大家都 ...
随机推荐
- Swing How to make dialogues
There are two types of dialog: modal non-modal: must use JDialog directly Taken JFileChooser as Exam ...
- GPS accuracy in Android
Get the estimated accuracy of this location, in meters. We define accuracy as the radius of 68% conf ...
- Android学习之ProgressBar
ProgressBar用于向用户显示某个耗时操作完成的百分比,避免长时间执行某个耗时操作时让用户感觉程序失去了响应,从而提高用户界面的友好性. 请看下面的界面布局: <LinearLayout ...
- JSP中文乱码解决方案
学习JSP的过程中总会碰到中文乱码问题,有的是post方式提交没问题,用get方式提交有乱码,还有的是部署到tomcat中没问题,在Eclipse中启动tomcat,发现用get方式提交有乱码.产生乱 ...
- 萝卜叶万能助手SEO网络营销简介
萝卜叶万能助手专业版是就是将我们10年的SEO经验和方法汇聚于一体的结晶,旨在打造一款使用简单方便,功能强大的SEO软件,以便节省您的时间,提高您收集资料.维护网站.发布帖子.进行网络营销的效率. 借 ...
- Selenium Grid 学习笔记
Selenium Grid 学习笔记http://www.docin.com/p-765680298.html
- C#的设计模式分为3大类23种
创建型: 1. 单件模式(Singleton Pattern) 2. 抽象工厂(Abstract Factory) 3. 建造者模式(Builder) 4. 工厂方法模式(Factory Method ...
- 编译安装 LLVM
本文记录 LLVM 的安装过程,比较繁琐,使用 LLVM 3.4 操作系统:CentOS 6.6 64 位 1. 下载需要的软件 相关软件下载地址:http://llvm.org/releases/d ...
- 读书笔记_Effective_C++_条款四十六:需要类型转换时请为模板定义非成员函数
这个条款可以看成是条款24的续集,我们先简单回顾一下条款24,它说了为什么类似于operator *这样的重载运算符要定义成非成员函数(是为了保证混合乘法2*SomeRational或者SomeRat ...
- Frogger(floyd变形)
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...