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回表次数 来提高查询性能,因为回表将导致扫描更多的数据块. 我们大家都 ...
随机推荐
- 実行時にMicrosoft.ACE.OLEDB.12.0プロバイダーはローカルコンピュータに登録されていませんが出てしまう
環境 Windows8 64bit Visual Studio 2010 Access 2010 32bit 接続プロバイダは「Microsoft.ACE.OLEDB.12.0」 対応 Downloa ...
- 优先队列求解Huffman编码 c++
优先队列小析 优先队列的模板: template <class T, class Container = vector<T>,class Compare = less< ...
- SQLSERVER建立MYSQL连接服务器
1. 在SQL SERVER端安装MYSQL的ODBC驱动 2. 在ODBC数据源添加MYSQL(控制面板\所有控制面板项\管理工具) 在用户DSN 和系统DSN添加配置驱动程序 注:字符集一定要和M ...
- PLSQL登录弹出空白框如何解决
转自:http://jingyan.baidu.com/article/066074d6760959c3c21cb0d6.html 出现登录弹出空白框这是由于win7的安全性提高了,在PLSQL ...
- Linux下动态链接库 与gcc 选项
-L 编译时查找动态链接库的路径 -lxxx(小写) e.g -lcudart = link libcudart.so , -I(大写) 头文件的路径 -rpath (-R), 编译时指定链接 ...
- 记录一个Word操作技巧,很偏门的,鉴于Google很不方便用了,百度起来比较费劲所以记录一下
拿到一篇文章需要修改时需要将文中某一段带有特定文字的段落删除,比如一段带有“淘宝网”文字的广告性宣传,且这种段落并不是全都一样,数量也很多,不太可能手动一段一段找到Delete,这就可以用这个替换查找 ...
- 免费国内外"代码托管服务器"收集
国内 开源中国 http://git.oschina.net/ 支持git 淘宝code http://code.taobao.org/ 支持svn 京东code https://cod ...
- VS2010 项目引用了微软企业库,但是编译时提示:未能找到类型或命名空间名称
我写的是控制台程序 是在引用我自己写的库 和 Microsoft.Practices.EnterpriseLibrary 时出现的问题 经过分析,和百度 找到了修改方法 打开 项目属性-->应 ...
- 使用Doxygen生成net帮助文档
一. 什么是Doxygen? Doxygen 是一个程序的文件产生工具,可将程序中的特定批注转换成为说明文件.通常我们在写程序时,或多或少都会写上批注,但是对于其它人而言,要直接探索程序里的批注,与打 ...
- python 字符串翻转
通过步进反转[::-1] ]##[::-1]通过步进反转print b