■查看哪些session正在使用哪些回滚段?
测试方法: 打开多个SQL*Plus窗口,一些做一些需要回滚的操作,如insert,delete等,一个执行以下的语句来监视。
col "回滚段名" format a10
col SID format 9990
col "用户名" format a10
col "操作程序" format a80
col status format a6 trunc
SELECT r.name "回滚段名",
s.sid,
s.serial#,
s.username "用户名",
t.status,
t.cr_get,
t.phy_io,
t.used_ublk,
t.noundo,
substr(s.program, 1, 78) "操作程序"
FROM sys.v_$session s,sys.v_$transaction t,sys.v_$rollname r
WHERE t.addr = s.taddr and t.xidusn = r.usn
ORDER BY t.cr_get,t.phy_io
/
■查询数据库中有效的字符集
SQL> col nls_charset_id for 9999
SQL> col nls_charset_name for a30
SQL> col hex_id for a20
SQL> select
nls_charset_id(value) nls_charset_id,
value nls_charset_name,
to_char(nls_charset_id(value),'xxxx') hex_id
from v$nls_valid_values
where parameter = 'CHARACTERSET'
order by nls_charset_id(value);
■查看oracle实例
SQL> select instance_name from v$instance;
■修改块跟踪文件
SQL> alter database enable block change tracking
2 using file
3 '/export/home/opt/product/10.2.0.1.0/admin/orcl/changed_blocks.bct';
Database altered.
禁用块跟踪文件
SQL> alter database disable block change tracking;
■创建表空间
CREATE SMALLFILE TABLESPACE "YUHJ_SPACE"
DATAFILE '/export/home/opt/product/oradata/orcl/yuhj_datafile'
SIZE 10M AUTOEXTEND ON NEXT 50K MAXSIZE 20M
LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
■创建临时表空间
CREATE SMALLFILE TEMPORARY TABLESPACE "YHJ_TEMP_SPACE"
TEMPFILE '/export/home/opt/product/oradata/orcl/yhj_tempfile' SIZE 5M
AUTOEXTEND ON NEXT 56K MAXSIZE 10M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
■创建数据文件
ALTER TABLESPACE "YUHJ_SPACE"
ADD DATAFILE '/export/home/opt/product/oradata/orcl/yhj_datafile' SIZE 2M
AUTOEXTEND ON NEXT 56K MAXSIZE UNLIMITED/15M
■创建回滚段
CREATE ROLLBACK SEGMENT "SYSTEM"
TABLESPACE "SYSTEM"
STORAGE (INITIAL 112K MINEXTENTS 1 MAXEXTENTS 32765 )
■改变回滚段状态(上线/离线)
ALTER ROLLBACK SEGMENT "SYSTEM" ONLINE/OFFLINE
■创建重做日志组
ALTER DATABASE ADD
LOGFILE GROUP 4 ( '/export/home/opt/product/oradata/orcl/redo4.log') SIZE 51200K
■设定SGA总大小
ALTER SYSTEM SET sga_target = 209715200 SCOPE=BOTH
■设定SGA最大在小
ALTER SYSTEM SET sga_max_size = 262144000 COMMENT='internally adjusted' SCOPE=SPFILE
说明:
"SGA 最大大小"指定数据库可以分配的最大内存.如果指定了"SGA 最大大小", 则以后可以动态
更改上述 SGA 总大小 (提供的 SGA 总大小不能超过 SGA 最大大小).
■设定PGA内存分配
ALTER SYSTEM SET pga_aggregate_target = 25769803776 SCOPE=BOTH
■改变会话日期格式
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
改变会话时区
ALTER SESSION SET TIME_ZONE = '-05:00';
改变数据库的时区
ALTER DATABASE SET TIME_ZONE = '-05:00';
■查询触发器
select * from user_triggers;
select * from all_triggers;
select * from dba_triggers;
■查询当前用户在emp表上创建的所有触发器
SQL> select trigger_name, status from user_triggers where table_name = 'EMP';
■禁止触发器
SQL> alter trigger tr_emp_time DISABLE;
■激活触发器
SQL> alter trigger tr_emp_time ENABLE;
■激活或禁止表上的所有触发器
SQL> alter table dept DISABLE ALL TRIGGERS;
SQL> alter table emp ENABLE ALL TRIGGERS;
■重新编译触发器
SQL> alter trigger tr_emp_time compile;
■删除触发器
SQL> drop trigger tr_emp_time;