分类: Oracle
2008-06-03 23:16:01
71、日志管理
<1>建立日志组
sql>select * from v$logfile;
sql>alter database add logfile group 3
('f:\orant\database\log1_g3.ora'
'f:\orant\database\log2_g3.ora') size 100k;
sql>select * from v$logfile;
----
sql> alter database add logfile group 4
('/disk3/log4a.rdo','/disk4/log4b.rdo') size 1m;
<2>删除日志组
alter database drop logfile group 1;
但是其物理文件并没有被删除掉
系统至少需要2个日志组,如果只有2个,就不能删除
不能删除正活动的日志组
<3>手工归档
通过alter system 的archive log 子句来实现
archive log [thread 整数]
[seq 整数][change 整数][current][group 整数]
[logfile '文件名'][next][all][start][to '位置']
<4> 强制日志切换
sql> alter system switch logfile;
<5> 强制checkpoints
sql> alter system checkpoint;
<6> adding online redo log members
sql>alter database add logfile member
'/disk3/log1b.rdo' to group 1,
'/disk4/log2b.rdo' to group 2;
<7>.changes the name of the online redo logfile
sql> alter database rename file 'c:/oracle/oradata/oradb/redo01.log'
to 'c:/oracle/oradata/redo01.log';
<8> drop online redo log members
sql> alter database drop logfile member 'c:/oracle/oradata/redo01.log';
<9>.clearing online redo log files
sql> alter database clear [unarchived] logfile 'c:/oracle/log2a.rdo';
<10>.using logminer analyzing redo logfiles
a. in the init.ora specify utl_file_dir = ' '
b. sql> execute dbms_logmnr_d.build('oradb.ora','c:\oracle\oradb\log');
c. sql> execute dbms_logmnr_add_logfile('c:\oracle\oradata\oradb\redo01.log',
sql> dbms_logmnr.new);
d. sql> execute dbms_logmnr.add_logfile('c:\oracle\oradata\oradb\redo02.log',
sql> dbms_logmnr.addfile);
e. sql> execute dbms_logmnr.start_logmnr(dictfilename=>'c:\oracle\oradb\log\oradb.ora');
f. sql> select * from v$logmnr_contents(v$logmnr_dictionary,v$logmnr_parameters
sql> v$logmnr_logs);
g. sql> execute dbms_logmnr.end_logmnr;
72 系统控制
alter system ...
alter system enable restricted session; 只允许具有restricted系统特权的用户登录
alter system flush shared_pool 清除共享池
alter system checkpoint 执行一 个检查点
alter system set license_max_session=64,license_session_warning=54 会话限制为64,会话的警界为54
alter system set license_max_session=0 会话数为无限制
alter system set license_max_users=300 用户限制为300个
alter system switch logfile 强制执行日志转换
73 会话控制
alter session
alter session set sql_trace=true 当前会话具有sql跟踪功能
alter session set NLS_language=French 出错信息设为法语
alter session set NLS_date_format='YYYY MM DD HH24:MI:SS';缺省日期格式
alter session set optimizier_goal=first_row改变优化方法为基于开销方法,具有快速响应速度
update student@teach set sold=sold+1 where sno='98010';
commit;
alter session close database link teach; 关闭远程链路
74、封锁机制
数据封锁:保护表数据,在多个用户并行存取数据时候,保证数据的完整性。
DML操作又在两个级别获取数据封锁:指定记录封锁和表封锁
表封锁可以有下列方式:行共享(RS),行排他(RX),共享封锁(S),共享行排他(SPX)和排他
封锁(X)
行共享表封锁(RS),允许其他事务并行查询、插入,修改和删除及再行封锁
select ...from 表名 ... for update of ...;
lock table 表名 in row share mode;
行排他表封锁(RX) 对该行有独占权利
insert into 表名 ...;
update 表名 ...;
delete from 表名 ...;
lock table 表名 in row exclusive mode;
允许并行查询、插入、删除或封锁其他行,但禁止其他事务使用下列命令进行并发封锁:
lock table 表名 in share mode;
lock table 表名 in share exclusive mode;
lock table 表名 in exclusive mode;
共享表封锁(S)
lock table 表名 in share mode;
允许其他事务可在该表上做查询和再实现共享表操作,但不能修改该表,同时也不能做如下封锁:
lock table 表名 in share row exclusive mode;
lock table 表名 in exclusive mode;
lock table 表名 in row exclusive mode;
共享排他表封锁(SRX)
lock table 表名 in share row exclusive mode;
排他表封锁(SRX)
lock table 表名 in exclusive mode;
75、设置事务
set transaction [read only][read write][use rollback segment 回滚段名]
76.如果希望用aimtzmcc用户连接数据库,访问aicbs用户的表,不在表名前缀"aicbs.",可以在建立数据库连接后发下面的命令
alter session set current_schema = aicbs;
77、表空间管理
<1> 创建表空间
sql> create tablespace tablespace_name datafile 'c:\oracle\oradata\file1.dbf' size 100m,
sql> 'c:\oracle\oradata\file2.dbf' size 100m minimum extent 550k [logging/nologging]
sql> default storage (initial 500k next 500k maxextents 500 pctinccease 0)
sql> [online/offline] [permanent/temporary] [extent_management_clause]
<2>.locally managed tablespace
sql> create tablespace user_data datafile 'c:\oracle\oradata\user_data01.dbf'
sql> size 500m extent management local uniform size 10m;
<3>.temporary tablespace
sql> create temporary tablespace temp tempfile 'c:\oracle\oradata\temp01.dbf'
sql> size 500m extent management local uniform size 10m;
<4>.change the storage setting
sql> alter tablespace app_data minimum extent 2m;
sql> alter tablespace app_data default storage(initial 2m next 2m maxextents 999);
<5>.taking tablespace offline or online
sql> alter tablespace app_data offline;
sql> alter tablespace app_data online;
<6>.read_only tablespace
sql> alter tablespace app_data read onlywrite;
<7>.droping tablespace
sql> drop tablespace app_data including contents;
<8>.enableing automatic extension of data files
sql> alter tablespace app_data add datafile 'c:\oracle\oradata\app_data01.dbf' size 200m
sql> autoextend on next 10m maxsize 500m;
<9>.change the size fo data files manually
sql> alter database datafile 'c:\oracle\oradata\app_data.dbf' resize 200m;
<10>.Moving data files: alter tablespace
sql> alter tablespace app_data rename datafile 'c:\oracle\oradata\app_data.dbf'
sql> to 'c:\oracle\app_data.dbf';
<11>.moving data files:alter database
sql> alter database rename file 'c:\oracle\oradata\app_data.dbf'
sql> to 'c:\oracle\app_data.dbf';
78、BACKUP and RECOVERY
<1>. v$sga,v$instance,v$process,v$bgprocess,v$database,v$datafile,v$sgastat
<2>. Rman need set dbwr_IO_slaves or backup_tape_IO_slaves and large_pool_size
<3>. Monitoring Parallel Rollback
v$fast_start_servers , v$fast_start_transactions
<4>.perform a closed database backup (noarchivelog)
shutdown immediate
cp files /backup/
startup
<5>.restore to a different location
connect system/manager as sysdba
startup mount
alter database rename file '/disk1/../user.dbf' to '/disk2/../user.dbf';
alter database open;
<6>.recover syntax
--recover a mounted database
recover database;
recover datafile '/disk1/data/df2.dbf';
alter database recover database;
--recover an opened database
recover tablespace user_data;
recover datafile 2;
alter database recover datafile 2;
<7>.how to apply redo log files automatically
set autorecovery on
recover automatic datafile 4;
<8>.complete recovery:
--method 1(mounted databae)
copy c:\backup\user.dbf c:\oradata\user.dbf
startup mount
recover datafile 'c:\oradata\user.dbf;
alter database open;
--method 2(opened database,initially opened,not system or rollback datafile)
copy c:\backup\user.dbf c:\oradata\user.dbf (alter tablespace offline)
recover datafile 'c:\oradata\user.dbf' or
recover tablespace user_data;
alter database datafile 'c:\oradata\user.dbf' online or
alter tablespace user_data online;
--method 3(opened database,initially closed not system or rollback datafile)
startup mount
alter database datafile 'c:\oradata\user.dbf' offline;
alter database open
copy c:\backup\user.dbf d:\oradata\user.dbf
alter database rename file 'c:\oradata\user.dbf' to 'd:\oradata\user.dbf'
recover datafile 'e:\oradata\user.dbf' or recover tablespace user_data;
alter tablespace user_data online;
--method 4(loss of data file with no backup and have all archive log)
alter tablespace user_data offline immediate;
alter database create datafile 'd:\oradata\user.dbf' as 'c:\oradata\user.dbf''
recover tablespace user_data;
alter tablespace user_data online
<9>.perform an open database backup
alter tablespace user_data begin backup;
copy files /backup/
alter database datafile '/c:/../data.dbf' end backup;
alter system switch logfile;
<10>.backup a control file
alter database backup controlfile to 'control1.bkp';
alter database backup controlfile to trace;
<11>.recovery (noarchivelog mode)
shutdown abort
cp files
startup
<12>.recovery of file in backup mode
alter database datafile 2 end backup;
<13>.clearing redo log file
alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1 unrecoverable datafile;
<14>.redo log recovery
alter database add logfile group 3 'c:\oradata\redo03.log' size 1000k;
alter database drop logfile group 1;
alter database open;
or >cp c:\oradata\redo02.log' c:\oradata\redo01.log
alter database clear logfile 'c:\oradata\log01.log';
79 managing password security and resources
<1>.controlling account lock and password
sql> alter user juncky identified by oracle account unlock;
<2>.user_provided password function
sql> function_name(userid in varchar2(30),password in varchar2(30),
old_password in varchar2(30)) return boolean
<3>.create a profile : password setting
sql> create profile grace_5 limit failed_login_attempts 3
sql> password_lock_time unlimited password_life_time 30
sql>password_reuse_time 30 password_verify_function verify_function
sql> password_grace_time 5;
<4>.altering a profile
sql> alter profile default failed_login_attempts 3
sql> password_life_time 60 password_grace_time 10;
<5>.drop a profile
sql> drop profile grace_5 [cascade];
<6>.create a profile : resource limit
sql> create profile developer_prof limit sessions_per_user 2
sql> cpu_per_session 10000 idle_time 60 connect_time 480;
<7>. view => resource_cost : alter resource cost
dba_Users,dba_profiles
<8>. enable resource limits
sql> alter system set resource_limit=true;
80.managing privileges
<1>.system privileges: view => system_privilege_map ,dba_sys_privs,session_privs
<2>.grant system privilege
sql> grant create session,create table to managers;
sql> grant create session to scott with admin option;
with admin option can grant or revoke privilege from any user or role;
<3>.sysdba and sysoper privileges:
sysoper: startup,shutdown,alter database openmount,alter database backup controlfile,
alter tablespace begin/end backup,recover database
alter database archivelog,restricted session
sysdba: sysoper privileges with admin option,create database,recover database until
<4>.password file members: view:=> v$pwfile_users
<5>.O7_dictionary_Accessibility =true restriction access to view or tables in other schema
<6>.revoke system privilege
sql> revoke create table from karen;
sql> revoke create session from scott;
<7>.grant object privilege
sql> grant execute on dbms_pipe to public;
sql> grant update(first_name,salary) on employee to karen with grant option;
<8>.display object privilege : view => dba_tab_privs, dba_col_privs
<9>.revoke object privilege
sql> revoke execute on dbms_pipe from scott [cascade constraints];
<10>.audit record view :=> sys.aud$
<11>. protecting the audit trail
sql> audit delete on sys.aud$ by access;
<12>.statement auditing
sql> audit user;
<13>.privilege auditing
sql> audit select any table by summit by access;
<14>.schema object auditing
sql> audit lock on summit.employee by access whenever successful;
<15>.view audit option : view=> all_def_audit_opts,dba_stmt_audit_opts,dba_priv_audit_opts,dba_obj_audit_opts
<16>.view audit result: view=> dba_audit_trail,dba_audit_exists,dba_audit_object,dba_audit_session,dba_audit_statement
81 manager role
<1>.create roles
sql> create role sales_clerk;
sql> create role hr_clerk identified by bonus;
sql> create role hr_manager identified externally;
<2>.modify role
sql> alter role sales_clerk identified by commission;
sql> alter role hr_clerk identified externally;
sql> alter role hr_manager not identified;
<3>.assigning roles
sql> grant sales_clerk to scott;
sql> grant hr_clerk to hr_manager;
sql> grant hr_manager to scott with admin option;
<4>.establish default role
sql> alter user scott default role hr_clerk,sales_clerk;
sql> alter user scott default role all;
sql> alter user scott default role all except hr_clerk;
sql> alter user scott default role none;
<5>.enable and disable roles
sql> set role hr_clerk;
sql> set role sales_clerk identified by commission;
sql> set role all except sales_clerk;
sql> set role none;
<6>.remove role from user
sql> revoke sales_clerk from scott;
sql> revoke hr_manager from public;
<7>.remove role
sql> drop role hr_manager;
<8>.display role information
view: =>dba_roles,dba_role_privs,role_role_privs,dba_sys_privs,role_sys_privs,role_tab_privs,session_roles
81.查询当前正在执行的job的情况
有时候对于需要执行的job查询执行情况,比如正在执行那条语句,或者想把job停下来等。一般不知道怎么查询到
job执行的session的sid.
方法一:
select * from dba_jobs_running
如果运行比较慢,加
select /*+ rule */* from dba_jobs_running
方法二:
<1>首先得到job号,从user_jobs或者dba_jobs
select * from user_jobs where upper(what) like '%MYPROGRAM%'
<2> 根据job号查询sid号
select * from v$lock where id2 = 3361910 and type ='JQ'
就可以查询到sid了
比如查询当前的执行什么语句
select sql_text from v$sqlarea a,v$lock b,v$session c,user_jobs d
where d.upper(what) like '%2004PRESENT%'
and d.job = b.id2
and b.type='JQ'
and b.sid = c.sid
and a.hash_value = c.sql_hash_value
and a.address = c.sql_address
82.怎么样给sqlplus安装帮助
[A]SQLPLUS的帮助必须手工安装,shell脚本为$ORACLE_HOME/bin/helpins
在安装之前,必须先设置SYSTEM_PASS环境变量,如:
$ setenv SYSTEM_PASS SYSTEM/MANAGER
$ helpins
如果不设置该环境变量,将在运行脚本的时候提示输入环境变量
当然,除了shell脚本,还可以利用sql脚本安装,那就不用设置环境变量了,但是,我们必须以system登录。
$ sqlplus system/manager
SQL> @?/sqlplus/admin/help/helpbld.sql helpus.sql
安装之后,你就可以象如下的方法使用帮助了
SQL> help index
83.如何移动数据文件
<1>、关闭数据库,利用os拷贝
a.shutdown immediate关闭数据库
b.在os下拷贝数据文件到新的地点
c.Startup mount 启动到mount下
d.Alter database rename datafile '老文件' to '新文件';
e.Alter database open; 打开数据库
<2>、利用Rman联机操作
RMAN> sql "alter database datafile ''file name'' offline";
RMAN> run {
2> copy datafile 'old file location'
3> to 'new file location';
4> switch datafile ' old file location'
5> to datafilecopy ' new file location';
6> }
RMAN> sql "alter database datafile ''file name'' online";
说明:利用OS拷贝也可以联机操作,不关闭数据库,与rman的步骤一样,利用rman与利用os拷贝的原理一样,在rman中copy是拷贝数据文件,相当于OS的cp,而switch则相当于alter database rename,用来更新控制文件。
84.如何管理联机日志组与成员
以下是常见操作,如果在OPA/RAC下注意线程号
增加一个日志文件组
Alter database add logfile [group n] '文件全名' size 10M;
在这个组上增加一个成员
Alter database add logfile member '文件全名' to group n;
在这个组上删除一个日志成员
Alter database drop logfile member '文件全名';
删除整个日志组
Alter database drop logfile group n;
85.怎么样计算REDO BLOCK的大小
[A]计算方法为(redo size + redo wastage) / redo blocks written + 16
具体见如下例子
SQL> select name ,value from v$sysstat where name like '%redo%';
NAME VALUE
--------------------------------------------------
redo synch writes 2
redo synch time 0
redo entries 76
redo size 19412
redo buffer allocation retries 0
redo wastage 5884
redo writer latching time 0
redo writes 22
redo blocks written 51
redo write time 0
redo log space requests 0
redo log space wait time 0
redo log switch interrupts 0
redo ordering marks 0
SQL> select (19412+5884)/51 + 16 '"Redo black(byte)" from dual;
Redo black(byte)
------------------
512
86.如果发现表中有坏块,如何检索其它未坏的数据
[A]首先需要找到坏块的ID(可以运行dbverify实现),假设为,假定文件编码为。运行下面的查询查找段名:
SELECT segment_name,segment_type,extent_id,block_id, blocks
from dba_extents t
where
file_id =
AND between block_id and (block_id + blocks - 1)
一旦找到坏段名称,若段是一个表,则最好建立一个临时表,存放好的数据。若段是索引,则删除它,再重建。
create table good_table
as
select from bad_table where rowid not in
(select rowid
from bad_table where substr(rowid,10,6) = )
在这里要注意8以前的受限ROWID与现在ROWID的差别。
还可以使用诊断事件10231
SQL> ALTER SYSTEM SET EVENTS '10231 trace name context forever,level 10';
创建一个临时表good_table的表中除坏块的数据都检索出来
SQL>CREATE TABLE good_table as select * from bad_table;
最后关闭诊断事件
SQL> ALTER SYSTEM SET EVENTS '10231 trace name context off ';
关于ROWID的结构,还可以参考dbms_rowid.rowid_create函数
87.怎么样备份控制文件
在线备份为一个二进制的文件
alter database backup controlfile to '$BACKUP_DEPT/controlfile.000' [reuse];
备份为文本文件方式
alter database backup controlfile to trace [resetlogsnoresetlogs];
88.控制文件损坏如何恢复
<1>、如果是损坏单个控制文件
只需要关闭数据库,拷贝一个好的数据文件覆盖掉坏的数据文件即可
或者是修改init.ora文件的相关部分
<2>、如果是损失全部控制文件,则需要创建控制文件或从备份恢复
创建控制文件的脚本可以通过alter database backup controlfile to trace获取。
89.怎么样热备份一个表空间
<1>Alter tablespace 名称 begin backup;
host cp 这个表空间的数据文件 目的地;
Alter tablespace 名称 end backup;
如果是备份多个表空间或整个数据库,只需要一个一个表空间的操作下来就可以了。
90.怎么快速得到整个数据库的热备脚本
<1>可以写一段类似的脚本
SQL>set serveroutput on
begin
dbms_output.enable(10000);
for bk_ts in (select distinct t.ts#,t.name from v$tablespace t,v$datafile d where t.ts#=d.ts#) loop
dbms_output.put_line('--'bk_ts.name);
dbms_output.put_line('alter tablespace 'bk_ts.name' begin backup;');
for bk_file in (select file#,name from v$datafile where ts#=bk_ts.ts#) loop
dbms_output.put_line('host cp 'bk_file.name' $BACKUP_DEPT/');
end loop;
dbms_output.put_line('alter tablespace 'bk_ts.name' end backup;');
end loop;
end;
/
91.丢失一个数据文件,但是没有备份,怎么样打开数据库
如果没有备份只能是删除这个数据文件了,会导致相应的数据丢失。
SQL>startup mount
--ARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline;
--NOARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline drop;
SQLl>Alter database open;
注意:该数据文件不能是系统数据文件
92.丢失一个数据文件,没有备份但是有该数据文件创建以来的归档怎么恢复
保证如下条件
a. 不能是系统数据文件
b. 不能丢失控制文件
如果满足以上条件,则
SQL>startup mount
SQL>Alter database create datafile 'file name' as 'file name' size ... reuse;
SQL>recover datafile n; -文件号
或者
SQL>recover datafile 'file name';
或者
SQL>recover database;
SQL>Alter database open;
93.联机日志损坏如何恢复
<1>、如果是非当前日志而且归档,可以使用
Alter database clear logfile group n来创建一个新的日志文件
如果该日志还没有归档,则需要用
Alter database clear unarchived logfile group n
<2>、如果是当前日志损坏,一般不能clear,则可能意味着丢失数据
如果有备份,可以采用备份进行不完全恢复
如果没有备份,可能只能用_allow_resetlogs_corruption=true来进行强制恢复了,但是,这样的方法是不建议的,最好在有Oracle support的指导下进行。
94.怎么样创建RMAN恢复目录
首先,创建一个数据库用户,一般都是RMAN,并给予recovery_catalog_owner角色权限
sqlplus sys
SQL> create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;
然后,用这个用户登录,创建恢复目录
rman catalog rman/rman
RMAN> create catalog tablespace tools;
RMAN> exit;
最后,你可以在恢复目录注册目标数据库了
rman catalog rman/rman target backdba/backdba
RMAN> register database;
95.怎么样在恢复的时候移动数据文件,恢复到别的地点
给一个RMAN的例子
run {
set until time 'Jul 01 1999 00:05:00';
allocate channel d1 type disk;
set newname for datafile '/u04/oracle/prod/sys1prod.dbf'
to '/u02/oracle/prod/sys1prod.dbf';
set newname for datafile '/u04/oracle/prod/usr1prod.dbf'
to '/u02/oracle/prod/usr1prod.dbf';
set newname for datafile '/u04/oracle/prod/tmp1prod.dbf'
to '/u02/oracle/prod/tmp1prod.dbf';
restore controlfile to '/u02/oracle/prod/ctl1prod.ora';
replicate controlfile from '/u02/oracle/prod/ctl1prod.ora';
restore database;
sql "alter database mount";
switch datafile all;
recover database;
sql "alter database open resetlogs";
release channel d1;
}
96.怎么从备份片(backuppiece)中恢复(restore)控制文件与数据文件
可以使用如下方法,在RMAN中恢复备份片的控制文件
restore controlfile from backuppiecefile;
如果是9i的自动备份,可以采用如下的方法
restore controlfile from autobackup;
但是,如果控制文件全部丢失,需要指定DBID,如SET DBID=?
自动备份控制文件的默认格式是%F,这个格式的形式为
c-IIIIIIIIII-YYYYMMDD-QQ,其中IIIIIIIIII就是DBID
至于恢复(restore)数据文件,oracle 816开始有个包dbms_backup_restore
在 nomount 状态下就可以执行,可以读 815甚至之前的备份片,读出来的文件用于恢复
可以在SQLPLUS中运行,如下
SQL>startup nomount
SQL> DECLARE
2 devtype varchar2(256);
3 done boolean;
4 BEGIN
5 devtype := dbms_backup_restore.deviceallocate('', params=>'');
6 dbms_backup_restore.restoresetdatafile;
7 dbms_backup_restore.restorecontrolfileto('E:\Oracle\oradata\penny\control01.ctl');
8 dbms_backup_restore.restoreDataFileto(1,'E:\Oracle\oradata\penny\system01.dbf');
9 dbms_backup_restore.restoreDataFileto(2,'E:\Oracle\oradata\penny\UNDOTBS01.DBF');
10 dbms_backup_restore.restoreDataFileto(3,'E:\ORACLE\ORADATA\PENNY\USERS01.DBF');
11 dbms_backup_restore.restorebackuppiece('D:\orabak\BACKUP_1_4_04F4IAJT.PENNY',done=>done);
12 END;
13 /
PL/SQL 过程已成功完成。
SQL> alter database mount;
[Q]Rman的format格式中的%s类似的东西代表什么意义
[A]可以参考如下
%c 备份片的拷贝数
%d 数据库名称
%D 位于该月中的第几天 (DD)
%M 位于该年中的第几月 (MM)
%F 一个基于DBID唯一的名称,这个格式的形式为c-IIIIIIIIII-YYYYMMDD-QQ,其中IIIIIIIIII为该数据库的DBID,YYYYMMDD为日期,QQ是一个1-256的序列
%n 数据库名称,向右填补到最大八个字符
%u 一个八个字符的名称代表备份集与创建时间
%p 该备份集中的备份片号,从1开始到创建的文件数
%U 一个唯一的文件名,代表%u_%p_%c
%s 备份集的号
%t 备份集时间戳
%T 年月日格式(YYYYMMDD)
97.执行exec dbms_logmnr_d.build('Logminer.ora','file Directory'),提示下标超界,怎么办
完整错误信息如下,
SQL> exec dbms_logmnr_d.build('Logminer.ora','file directory')
BEGIN dbms_logmnr_d.build('Logminer.ora','file directory'); END;
*
ERROR 位于第 1 行:
ORA-06532: 下标超出限制
ORA-06512: 在"SYS.DBMS_LOGMNR_D", line 793
ORA-06512: 在line 1
解决办法为:
<1>.编辑位于"$ORACLE_HOME/rdbms/admin"目录下的文件"dbmslmd.sql"
改变行:
TYPE col_desc_array IS VARRAY(513) OF col_description;
为
TYPE col_desc_array IS VARRAY(700) OF col_description;
并保存文件
<2>. 运行改变后的脚本
SQLPLUS> Connect internal
SQLPLUS> @$ORACLE_HOME/rdbms/admin/dbmslmd.sql
<3>.重新编译该包
SQLPLUS> alter package DBMS_LOGMNR_D compile body;
98.执行execute dbms_logmnr.start_logmnr(DictFileName=>'DictFileName')提示ORA-01843:无效的月份,这个是什么原因
我们分析start_logmnr包
PROCEDURE start_logmnr(
startScn IN NUMBER default 0 ,
endScn IN NUMBER default 0,
startTime IN DATE default TO_DATE('01-jan-1988','DD-MON-YYYY'),
endTime IN DATE default TO_DATE('01-jan-2988','DD-MON-YYYY'),
DictFileName IN VARCHAR2 default '',
Options IN BINARY_INTEGER default 0 );
可以知道,如果TO_DATE('01-jan-1988','DD-MON-YYYY')失败,将导致以上错误
所以解决办法可以为
<1>、Alter session set NLS_LANGUAGE=American
<2>、用类似如下的方法执行
execute dbms_logmnr.start_logmnr (DictFileName=> 'f:\temp2\TESTDICT.ora', starttime => TO_DATE(
'01-01-1988','DD-MM-YYYY'), endTime=>TO_DATE('01-01-2988','DD-MM-YYYY'));