SQL> recover datafile ‘C:\app\Administrator\oradata\orcl\CCEN’;
完成介质恢复。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01113: 文件 7 需要介质恢复
ORA-01110: 数据文件 7: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01’
SQL> recover datafile ‘C:\app\Administrator\oradata\orcl\DETAIL01’;
完成介质恢复。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01113: 文件 8 需要介质恢复
ORA-01110: 数据文件 8: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02’
SQL> recover datafile ‘C:\app\Administrator\oradata\orcl\DETAIL02’;
select file_id,block_id,blocks from dba_extents where segment_name=‘SYSTEM’;
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-01578: ORACLE data block corrupted (file # 3, block # 160)
ORA-01110: data file 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
进程 ID: 1748
会话 ID: 1 序列号: 5
E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
E:\APP\ADMINISTRATOR\ORADATA\CCEN
E:\APP\ADMINISTRATOR\ORADATA\DETAIL01
E:\APP\ADMINISTRATOR\ORADATA\DETAIL02
E:\APP\ADMINISTRATOR\ORADATA\DETAIL03
E:\APP\ADMINISTRATOR\ORADATA\DETAIL04
已选择10行。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF’;
数据库已更改。
SQL> alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
’ to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF’;
数据库已更改。
SQL> alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
’ to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\CCEN’ to ‘C:\APP\A
DMINISTRATOR\ORADATA\ORCL\CCEN’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL01’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL02’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL03’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL04’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04’;
数据库已更改。
SQL> select name from v$tempfile;
E:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF
E:\APP\ADMINISTRATOR\ORADATA\CCEN_TMP
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\CCEN_TMP’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\CCEN_TMP’;
数据库已更改。
SQL> select member from v$logfile;
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG’;
数据库已更改。
SQL> select name from v$controlfile;
C:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL01.CTL
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL
SQL> select checkpoint_change# from v$database;
125406485
SQL> select checkpoint_change# from v$datafile;
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
已选择10行。
SQL> select checkpoint_change# from v$datafile_header;
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
已选择10行。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-00600: 内部错误代码, 参数: [kcratr_nab_less_than_odr], [1], [5380],
[11424], [12457], [], [], [], [], [], [], []
SQL> recover database;
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
CANCEL
ORA-01547: 警告: RECOVER 成功但 OPEN RESETLOGS 将出现如下错误
ORA-01194: 文件 1 需要更多的恢复来保持一致性
ORA-01110: 数据文件 1: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’
ORA-01112: 未启动介质恢复
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
ORA-01112: 未启动介质恢复
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
orcl MOUNTED
SQL> show parameter undo;
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter system set undo_management=‘AUTO’ scope=spfile;
系统已更改。
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
ORA-01112: 未启动介质恢复
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [2662], [0], [125406496], [0],
[125414494], [12583040], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [2662], [0], [125406495], [0],
[125414494], [12583040], [], [], [], [], [], []
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [2662], [0], [125406493], [0],
[125414494], [12583040], [], [], [], [], [], []
进程 ID: 3216
会话 ID: 1 序列号: 5
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> select checkpoint_change# from v$database;
125406489
SQL> select checkpoint_change# from v$datafile;
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
已选择10行。
SQL> select checkpoint_change# from v$datafile_header;
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
已选择10行。
SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-01139: RESETLOGS 选项仅在不完全数据库恢复后有效
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-30012: undo tablespace ‘UNDOTBS01’ does not exist or of wrong type
进程 ID: 3984
会话 ID: 1 序列号: 5
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 19:43:24 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> desc v$tablespace
名称 是否为空? 类型
TS# NUMBER
NAME VARCHAR2(30)
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
BIGFILE VARCHAR2(3)
FLASHBACK_ON VARCHAR2(3)
ENCRYPT_IN_BACKUP VARCHAR2(3)
SQL> select name from v$tablespace;
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
CCEN
CCEN_TMP
DETAIL01
DETAIL02
DETAIL03
DETAIL04
已选择12行。
######################创建参数文件更改undo参数 重建undo表空间失败
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter system set undo_tablespace=‘UNDOTBS1’ scope=spfile;
系统已更改。
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
进程 ID: 4084
会话 ID: 1 序列号: 5
SQL> alter database open resetlogs;
ERROR:
ORA-03114: 未连接到 ORACLE
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 19:54:39 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS1
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
####创建参数文件更改undo参数 重建undo表空间成功
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 20:05:05 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create pfile from spfile;
文件已创建。
修改C:\app\Administrator\product\11.2.0\dbhome_1\database\INITorcl.ORA中的*.undo_management=‘MANUAL’
*.undo_tablespace=’’
SQL> show parameter spfile;
NAME TYPE
spfile string
C:\APP\ADMINISTRATOR\PRODUCT\1
1.2.0\DBHOME_1\DATABASE\SPFILE
ORCL.ORA
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> create spfile from pfile=‘C:\app\Administrator\product\11.2.0\dbhome_1\data
base\INITorcl.ORA’;
文件已创建。
SQL> startup nomount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
SQL> show parameter undo
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
SQL> alter database mount;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> select name from v$datafile;
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\CCEN
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04
已选择10行。
SQL> create undo tablespace UNDOTBS2 datafile ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL
\UNDOTBS02.DBF’ size 100m autoextend on maxsize unlimited;
表空间已创建。
SQL> show parameter undo
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
SQL> alter system set undo_management=auto scope=spfile;
系统已更改。
SQL> alter system set undo_tablespace=undotbs2 scope=spfile;
系统已更改。
SQL> drop tablespace undotbs1 including contents and datafiles;
表空间已删除。
################################乱码问题
一、问题描述:
在将其它数据库的数据导出文件导入本地新建数据库时,所导入的数据全部是乱码,一般表现为数据表中列的值类似于"???",即内容大部分为?的表现形式。初步判断是因为Oracle客户端与数据库编码不一致所导致。乱码问题在各类技术很多地方都普遍可能存在,其根本原因主要是数据编码不一致导致。根据其原理排查数据编码,基本都可以解决乱码问题。
二、解决办法:
第一步:就Oracle数据库而言,可以使用sqlplus工具或者PL/SQL工具,登录数据库后,执行 select userenv(‘language’) from dual;语句,该语句可以查询当前数据库所使用的编码格式。这里使用sqlplus登录数据库,并执行上述查询语句,如下图所示:
select userenv(‘language’) from dual
“USERENV(‘LANGUAGE’)”
“SIMPLIFIED CHINESE_CHINA.AL32UTF8”
操作系统增加系统变量
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
乱码问题
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 20:23:19 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$nls_parameters where parameter =‘NLS_CHARACTERSET’;
NLS_CHARACTERSET
AL32UTF8
SQL> select userenv(‘language’) from dual;
SIMPLIFIED CHINESE_CHINA.AL32UTF8
Oracle语言环境变量配置
创建系统环境变量,以下为GBK和UTF8两种模式:
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.AL32UTF8
################################
坏块
select owner,segment_name,segment_type from dba_extents where file_id=1 and 71013 between block_id and block_id+blocks-1;
“OWNER” “SEGMENT_NAME” “SEGMENT_TYPE”
“SYS” “I_MON_MODS$_OBJ” “INDEX”
select table_name,index_name from dba_indexes where index_name like 'I_MON_MODS O B J ′ ; " T A B L E N A M E " " I N D E X N A M E " " M O N M O D S _OBJ'; "TABLE_NAME" "INDEX_NAME" "MON_MODS OBJ′;"TABLENAME""INDEXNAME""MONMODS" “I_MON_MODS$_OBJ”
alter index I_MON_MODS$_OBJ rebuild online;
/
Errors in file c:\app\administrator\diag\rdbms\orcl\orcl\trace\orcl_j002_2764.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: index key not found, obj# 289, file 1, block 2025 (2)
ORA-12012: error on auto execute of job 4002
ORA-08102: index key not found, obj# 289, file 1, block 2025 (2)
SELECT owner, object_name, object_type
FROM Dba_Objects
WHERE object_id IN (289);
可以查出object_name的名字,发现是表TB_WARE的索引,然后重建索引
“OWNER” “OBJECT_NAME” “OBJECT_TYPE”
“SYS” “I_JOB_NEXT” “INDEX”
select index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
index_name
I_JOB_NEXT
select table_name,index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
“TABLE_NAME” “INDEX_NAME”
“JOB$” “I_JOB_NEXT”
alter index PK_TB_WARE rebuild online; (记得要用rebuild online ,因为他会重新读表来创建索引,而rebuild可能会读取原先的索引段而不会去读表)
SELECT owner,object_name,object_type FROM Dba_Objects WHERE object_id IN (‘289’);
select index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
/
desc dba_indexes
/
select table_name,index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
/
alter index I_JOB_NEXT rebuild online;
SQL> col file_name for a50
SQL> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
4 C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
2 C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
1 C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
5 C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
6 C:\APP\ADMINISTRATOR\ORADATA\ORCL\CCEN
7 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01
8 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02
9 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03
10 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04
11 C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS02.DBF
已选择10行。
alter system checkpoint;
alter system switch logfile;
###########################
修复数据库成功
SQL> shu immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
数据库已经打开。
########导出数据库文件
SQL> create directory export as ‘E:\bak’;
目录已创建。
SQL> grant read,write on directory export to ccense;
授权成功。
C:\Users\Administrator>expdp system/orcl directory=export dumpfile=20200512.dmp
logfile=20200512.log schemas=ccenseSQL> recover datafile ‘C:\app\Administrator\oradata\orcl\CCEN’;
完成介质恢复。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01113: 文件 7 需要介质恢复
ORA-01110: 数据文件 7: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01’
SQL> recover datafile ‘C:\app\Administrator\oradata\orcl\DETAIL01’;
完成介质恢复。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01113: 文件 8 需要介质恢复
ORA-01110: 数据文件 8: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02’
SQL> recover datafile ‘C:\app\Administrator\oradata\orcl\DETAIL02’;
select file_id,block_id,blocks from dba_extents where segment_name=‘SYSTEM’;
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-01578: ORACLE data block corrupted (file # 3, block # 160)
ORA-01110: data file 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
进程 ID: 1748
会话 ID: 1 序列号: 5
E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
E:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
E:\APP\ADMINISTRATOR\ORADATA\CCEN
E:\APP\ADMINISTRATOR\ORADATA\DETAIL01
E:\APP\ADMINISTRATOR\ORADATA\DETAIL02
E:\APP\ADMINISTRATOR\ORADATA\DETAIL03
E:\APP\ADMINISTRATOR\ORADATA\DETAIL04
已选择10行。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF’;
数据库已更改。
SQL> alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
’ to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF’
to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF’;
数据库已更改。
SQL> alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
’ to ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\CCEN’ to ‘C:\APP\A
DMINISTRATOR\ORADATA\ORCL\CCEN’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL01’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL02’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL03’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\DETAIL04’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04’;
数据库已更改。
SQL> select name from v$tempfile;
E:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF
E:\APP\ADMINISTRATOR\ORADATA\CCEN_TMP
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\CCEN_TMP’ to ‘C:\A
PP\ADMINISTRATOR\ORADATA\ORCL\CCEN_TMP’;
数据库已更改。
SQL> select member from v$logfile;
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG
E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO02.LOG’;
数据库已更改。
SQL> alter database rename file ‘E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG’ t
o ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO03.LOG’;
数据库已更改。
SQL> select name from v$controlfile;
C:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL01.CTL
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL
SQL> select checkpoint_change# from v$database;
125406485
SQL> select checkpoint_change# from v$datafile;
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
已选择10行。
SQL> select checkpoint_change# from v$datafile_header;
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
125406485
已选择10行。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-00600: 内部错误代码, 参数: [kcratr_nab_less_than_odr], [1], [5380],
[11424], [12457], [], [], [], [], [], [], []
SQL> recover database;
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
CANCEL
ORA-01547: 警告: RECOVER 成功但 OPEN RESETLOGS 将出现如下错误
ORA-01194: 文件 1 需要更多的恢复来保持一致性
ORA-01110: 数据文件 1: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF’
ORA-01112: 未启动介质恢复
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
ORA-01112: 未启动介质恢复
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
orcl MOUNTED
SQL> show parameter undo;
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter system set undo_management=‘AUTO’ scope=spfile;
系统已更改。
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> recover database using backup controlfile until cancel;
ORA-00279: 更改 125406485 (在 05/09/2020 16:51:14 生成) 对于线程 1 是必需的
ORA-00289: 建议:
C:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2020_05_12\O1_MF_1_5380
%U.ARC
ORA-00280: 更改 125406485 (用于线程 1) 在序列 #5380 中
指定日志: {=suggested | filename | AUTO | CANCEL}
C:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO01.LOG
ORA-00283: 恢复会话因错误而取消
ORA-00600: 内部错误代码, 参数: [3020], [3], [160], [12583072], [], [], [], [],
[], [], [], []
ORA-10567: Redo is inconsistent with data block (file# 3, block# 160, file
offset is 1310720 bytes)
ORA-10564: tablespace UNDOTBS1
ORA-01110: 数据文件 3: ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF’
ORA-10560: block type ‘KTU SMU HEADER BLOCK’
ORA-01112: 未启动介质恢复
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [2662], [0], [125406496], [0],
[125414494], [12583040], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [2662], [0], [125406495], [0],
[125414494], [12583040], [], [], [], [], [], []
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [2662], [0], [125406493], [0],
[125414494], [12583040], [], [], [], [], [], []
进程 ID: 3216
会话 ID: 1 序列号: 5
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> select checkpoint_change# from v$database;
125406489
SQL> select checkpoint_change# from v$datafile;
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
已选择10行。
SQL> select checkpoint_change# from v$datafile_header;
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
125406489
已选择10行。
SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-01139: RESETLOGS 选项仅在不完全数据库恢复后有效
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-30012: undo tablespace ‘UNDOTBS01’ does not exist or of wrong type
进程 ID: 3984
会话 ID: 1 序列号: 5
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 19:43:24 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> desc v$tablespace
名称 是否为空? 类型
TS# NUMBER
NAME VARCHAR2(30)
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
BIGFILE VARCHAR2(3)
FLASHBACK_ON VARCHAR2(3)
ENCRYPT_IN_BACKUP VARCHAR2(3)
SQL> select name from v$tablespace;
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
CCEN
CCEN_TMP
DETAIL01
DETAIL02
DETAIL03
DETAIL04
已选择12行。
######################创建参数文件更改undo参数 重建undo表空间失败
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS01
SQL> alter system set undo_tablespace=‘UNDOTBS1’ scope=spfile;
系统已更改。
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
ORA-00600: internal error code, arguments: [4193], [], [], [], [], [], [], [],
[], [], [], []
进程 ID: 4084
会话 ID: 1 序列号: 5
SQL> alter database open resetlogs;
ERROR:
ORA-03114: 未连接到 ORACLE
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 19:54:39 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
SQL> show parameter undo
NAME TYPE
undo_management string
AUTO
undo_retention integer
900
undo_tablespace string
UNDOTBS1
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开
####创建参数文件更改undo参数 重建undo表空间成功
C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 20:05:05 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create pfile from spfile;
文件已创建。
修改C:\app\Administrator\product\11.2.0\dbhome_1\database\INITorcl.ORA中的*.undo_management=‘MANUAL’
*.undo_tablespace=’’
SQL> show parameter spfile;
NAME TYPE
spfile string
C:\APP\ADMINISTRATOR\PRODUCT\1
1.2.0\DBHOME_1\DATABASE\SPFILE
ORCL.ORA
SQL> shu immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> create spfile from pfile=‘C:\app\Administrator\product\11.2.0\dbhome_1\data
base\INITorcl.ORA’;
文件已创建。
SQL> startup nomount;
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
SQL> show parameter undo
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
SQL> alter database mount;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> select name from v$datafile;
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\CCEN
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04
已选择10行。
SQL> create undo tablespace UNDOTBS2 datafile ‘C:\APP\ADMINISTRATOR\ORADATA\ORCL
\UNDOTBS02.DBF’ size 100m autoextend on maxsize unlimited;
表空间已创建。
SQL> show parameter undo
NAME TYPE
undo_management string
MANUAL
undo_retention integer
900
undo_tablespace string
SQL> alter system set undo_management=auto scope=spfile;
系统已更改。
SQL> alter system set undo_tablespace=undotbs2 scope=spfile;
系统已更改。
SQL> drop tablespace undotbs1 including contents and datafiles;
表空间已删除。
################################乱码问题
一、问题描述:
在将其它数据库的数据导出文件导入本地新建数据库时,所导入的数据全部是乱码,一般表现为数据表中列的值类似于"???",即内容大部分为?的表现形式。初步判断是因为Oracle客户端与数据库编码不一致所导致。乱码问题在各类技术很多地方都普遍可能存在,其根本原因主要是数据编码不一致导致。根据其原理排查数据编码,基本都可以解决乱码问题。
二、解决办法:
第一步:就Oracle数据库而言,可以使用sqlplus工具或者PL/SQL工具,登录数据库后,执行 select userenv(‘language’) from dual;语句,该语句可以查询当前数据库所使用的编码格式。这里使用sqlplus登录数据库,并执行上述查询语句,如下图所示:
select userenv(‘language’) from dual
“USERENV(‘LANGUAGE’)”
“SIMPLIFIED CHINESE_CHINA.AL32UTF8”
操作系统增加系统变量
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
乱码问题
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 5月 12 20:23:19 2020
Copyright © 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$nls_parameters where parameter =‘NLS_CHARACTERSET’;
NLS_CHARACTERSET
AL32UTF8
SQL> select userenv(‘language’) from dual;
SIMPLIFIED CHINESE_CHINA.AL32UTF8
Oracle语言环境变量配置
创建系统环境变量,以下为GBK和UTF8两种模式:
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
变量名:NLS_LANG
变量值:SIMPLIFIED CHINESE_CHINA.AL32UTF8
################################
坏块
select owner,segment_name,segment_type from dba_extents where file_id=1 and 71013 between block_id and block_id+blocks-1;
“OWNER” “SEGMENT_NAME” “SEGMENT_TYPE”
“SYS” “I_MON_MODS$_OBJ” “INDEX”
select table_name,index_name from dba_indexes where index_name like 'I_MON_MODS O B J ′ ; " T A B L E N A M E " " I N D E X N A M E " " M O N M O D S _OBJ'; "TABLE_NAME" "INDEX_NAME" "MON_MODS OBJ′;"TABLENAME""INDEXNAME""MONMODS" “I_MON_MODS$_OBJ”
alter index I_MON_MODS$_OBJ rebuild online;
/
Errors in file c:\app\administrator\diag\rdbms\orcl\orcl\trace\orcl_j002_2764.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: index key not found, obj# 289, file 1, block 2025 (2)
ORA-12012: error on auto execute of job 4002
ORA-08102: index key not found, obj# 289, file 1, block 2025 (2)
SELECT owner, object_name, object_type
FROM Dba_Objects
WHERE object_id IN (289);
可以查出object_name的名字,发现是表TB_WARE的索引,然后重建索引
“OWNER” “OBJECT_NAME” “OBJECT_TYPE”
“SYS” “I_JOB_NEXT” “INDEX”
select index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
index_name
I_JOB_NEXT
select table_name,index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
“TABLE_NAME” “INDEX_NAME”
“JOB$” “I_JOB_NEXT”
alter index PK_TB_WARE rebuild online; (记得要用rebuild online ,因为他会重新读表来创建索引,而rebuild可能会读取原先的索引段而不会去读表)
SELECT owner,object_name,object_type FROM Dba_Objects WHERE object_id IN (‘289’);
select index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
/
desc dba_indexes
/
select table_name,index_name from dba_indexes where index_name like ‘I_JOB_NEXT’;
/
alter index I_JOB_NEXT rebuild online;
SQL> col file_name for a50
SQL> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
4 C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
2 C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
1 C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
5 C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
6 C:\APP\ADMINISTRATOR\ORADATA\ORCL\CCEN
7 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL01
8 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL02
9 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL03
10 C:\APP\ADMINISTRATOR\ORADATA\ORCL\DETAIL04
11 C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS02.DBF
已选择10行。
alter system checkpoint;
alter system switch logfile;
###########################
修复数据库成功
SQL> shu immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 1286066176 bytes
Fixed Size 2175408 bytes
Variable Size 788532816 bytes
Database Buffers 486539264 bytes
Redo Buffers 8818688 bytes
数据库装载完毕。
数据库已经打开。
########导出数据库文件
SQL> create directory export as ‘E:\bak’;
目录已创建。
SQL> grant read,write on directory export to ccense;
授权成功。
C:\Users\Administrator>expdp system/orcl directory=export dumpfile=20200512.dmp
logfile=20200512.log schemas=ccense