Oracle常用系统表查询
-- get all dictionary for oracle db
select * from dict;
--select * from dictionary;
-- get all columns for dictionarys
select * from dict_columns;
-- get the default name-space for current user
select username,default_tablespace from user_users;
-- get roles for current user
select * from user_role_privs;
-- get system privilage and table privilage for current user
select * from user_sys_privs;
select * from user_tab_privs;
-- get all tables for current user
select * from user_tables;
-- get all tables whoes name includes log
select object_name,object_id from user_objects where instr(object_name,'LOG')>0
-- get the create date for a table
select object_name,created from user_objects where object_name=upper('&table_name');
-- get the size for the given table
select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&table_name');
-- get tables in ram
select table_name,cache from user_tables where instr(cache,'Y')>0
-- get index couter and types
select index_name,index_type,table_name from user_indexes order by table_name
-- get the columns indexed by the given index
select * from user_ind_columns where index_name=upper('&index_name')
-- get the size for the given index
select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&index_name')
-- get the last number for all sequence
select * from user_sequences
-- get all views
select view_name from user_views
-- get the sql to defined the given view
select view_name,text_length from user_views;
set long 417;
select text from user_views where view_name=upper('&view_name');
-- get all synonyms
select * from user_synonyms
-- get constraints for given table
select constraint_name, constraint_type,search_condition, r_constraint_name from
user_constraints where table_name = upper('&table_name');
select c.constraint_name,c.constraint_type,cc.column_name
from us
相关文档:
ORACLE游标
游标:容器,存放当前SQL语句影响的记录
所有DML语句都会用到游标
逐行处理影响的行数
游标
静态游标:游标与SQL语句在运行前关联
&nb ......
程序包
包主体/规范名字一样
包主体/规范中的对应参数必须类型及名字一样
只能使用强类型的REF游标
创建程序包规范
create or replace package my_pack
is
procedure find_emp_proc(eno emp.empno%type);
function fin ......
导出和导入实用程序
q 导出和导入实用程序用于实施数据库的逻辑备份和恢复
q 导出实用程序将数据库中的对象定义和数据备份到一个操作系统二进制文件中
q 导入实用程序读取二进制导出文件并将对象和数据载入数据库中 ......
Oracle SQL PLUS 基本操作1
登录
c:\>sqlplus "sys/test1234 as sysdba" 以sysdba身份登录
c:\>sqlplus/nolog 以nolog身份登录
sql> connect sys/test1234 as sysdba
Connected.
启动
SQL> startup &nb ......