`

oracle关于字符集的两个小工具

 
阅读更多

oracle提供了两个工具用来修改字符集,Database Character Set Scanner(csscan)和Language and Character Set File Scanner(lcsscan)。

下面简单介绍下这两个工具的使用:

一、csscan

csscan是Oracle提供的一个用于检查字符集转换过程中可能会出现的数据丢失或者损坏的情况。也可以单独的扫描某些表某些列能否进行字符集转换,并且能够并行扫描以加快扫描速度。

1.首先以sys用户身份创建用户(CSMIG)和相应的数据字典视图,否则在运行的时候会提示CSS-00107错误:

[oracle@oracle ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Apr 17 16:44:43 2008

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @@?/rdbms/admin/csminst.sql

Grant succeeded.

Grant succeeded.

drop user csmig cascade
*
ERROR at line 1:
ORA-01918: user 'CSMIG' does not exist

Please create password for user CSMIG:
Enter value for csmig_passwd: iloveyou
old 1: create user csmig identified by &csmig_passwd
new 1: create user csmig identified by iloveyou

User created.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

User altered.

1 row created.

1 row updated.

Table created.

drop public synonym csm$parameters
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$query
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$tables
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$columns
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$extables
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$errors
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$langid
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$charsetid
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$indexes
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$constraints
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$triggers
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

Table created.

drop public synonym csm$dictusers
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

Grant succeeded.

14 rows created.

View created.

drop public synonym csmv$tables
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

drop public synonym csmv$columns
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

drop public synonym csmv$errors
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

drop public synonym csmv$indexes
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

drop public synonym csmv$constraints
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

drop public synonym csmv$triggers
*
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist

Synonym created.

View created.

View created.

View created.

View created.

Grant succeeded.

Grant succeeded.

Commit complete.

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

2.脚本执行完成之后,执行csscan符集扫描工具,并查看输出报告:

[oracle@oracle ~]$ csscan system/thunis


Character Set Scanner v2.1 : Release 10.2.0.3.0 - Production on Thu Apr 17 16:50:14 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

(1)Full database, (2)User, (3)Table, (4)Column: 1 > 2

Current database character set is WE8ISO8859P1.

Enter new database character set name: > WE8ISO8859P1

Enter array fetch buffer size: 1024000 >

Enter number of scan processes to utilize(1..32): 1 >

Enter user name to scan: > hr

Enumerating tables to scan...

. process 1 scanning HR.REGIONS[AAAMgrAAFAAAAAJAAA]
. process 1 scanning HR.EMPLOYEES[AAAMg3AAFAAAABRAAA]
. process 1 scanning HR.DP_TEST[AAAM48AAEAAAAG5AAA]
. process 1 scanning HR.JOB_HISTORY[AAAMg7AAFAAAABpAAA]
. process 1 scanning HR.LOCATIONS[AAAMgvAAFAAAAAhAAA]
. process 1 scanning HR.JOBS[AAAMg1AAFAAAABBAAA]
. process 1 scanning HR.CUSTOMERS[AAAM3mAAEAAAAGBAAA]
. process 1 scanning HR.DEPARTMENTS[AAAMgyAAFAAAAAxAAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.

[oracle@oracle ~]$ ll -st|grep scan
8 -rw-r--r-- 1 oracle oinstall 1217 Apr 17 16:52 scan.out
8 -rw-r--r-- 1 oracle oinstall 1437 Apr 17 16:52 scan.err
12 -rw-r--r-- 1 oracle oinstall 5561 Apr 17 16:51 scan.txt

[oracle@oracle ~]$ pwd
/home/oracle

[oracle@oracle ~]$ more scan.err
Database Scan Individual Exception Report


[Database Scan Parameters]

Parameter Value
------------------------------ ------------------------------------------------
CSSCAN Version v2.1
Instance Name test
Database Version 10.2.0.4.0
Scan type User tables
User name hr
Scan CHAR data? YES
Database character set WE8ISO8859P1
FROMCHAR WE8ISO8859P1
TOCHAR WE8ISO8859P1
Scan NCHAR data? NO
Array fetch buffer size 1024000
Number of processes 1
Capture convertible data? NO
------------------------------ ------------------------------------------------

[Data Dictionary individual exceptions]


[Application data individual exceptions]

[oracle@oracle ~]$ more scan.out


Character Set Scanner v2.1 : Release 10.2.0.3.0 - Production on Thu Apr 17 16:50:14 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

(1)Full database, (2)User, (3)Table, (4)Column: 1 >
Current database character set is WE8ISO8859P1.

Enter new database character set name: >
Enter array fetch buffer size: 1024000 >
Enter number of scan processes to utilize(1..32): 1 >

Enter user name to scan: > hr
Enumerating tables to scan...

. process 1 scanning HR.REGIONS[AAAMgrAAFAAAAAJAAA]
. process 1 scanning HR.EMPLOYEES[AAAMg3AAFAAAABRAAA]
. process 1 scanning HR.DP_TEST[AAAM48AAEAAAAG5AAA]
. process 1 scanning HR.JOB_HISTORY[AAAMg7AAFAAAABpAAA]
. process 1 scanning HR.LOCATIONS[AAAMgvAAFAAAAAhAAA]
. process 1 scanning HR.JOBS[AAAMg1AAFAAAABBAAA]
. process 1 scanning HR.CUSTOMERS[AAAM3mAAEAAAAGBAAA]
. process 1 scanning HR.DEPARTMENTS[AAAMgyAAFAAAAAxAAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.

[oracle@oracle ~]$ more scan.txt
Database Scan Summary Report

Time Started : 2008-04-17 16:51:24
Time Completed: 2008-04-17 16:51:57

Process ID Time Started Time Completed
---------- -------------------- --------------------
1 2008-04-17 16:51:54 2008-04-17 16:51:55
---------- -------------------- --------------------

[Database Size]

Tablespace Used Free Total Expansion
------------------------- --------------- --------------- --------------- ---------------
SYSTEM 507.06M 2.94M 510.00M .00K
UNDOTBS1 13.31M 206.69M 220.00M .00K
SYSAUX 267.75M 12.25M 280.00M .00K
TEMP .00K .00K .00K .00K
USERS 3.50M 1.50M 5.00M .00K
EXAMPLE 68.25M 31.75M 100.00M .00K
------------------------- --------------- --------------- --------------- ---------------
Total 859.88M 255.13M 1,115.00M .00K

[Database Scan Parameters]

Parameter Value
------------------------------ ------------------------------------------------
CSSCAN Version v2.1
Instance Name test
Database Version 10.2.0.4.0
Scan type User tables
User name hr
Scan CHAR data? YES
Database character set WE8ISO8859P1
FROMCHAR WE8ISO8859P1
TOCHAR WE8ISO8859P1
Scan NCHAR data? NO
Array fetch buffer size 1024000
Number of processes 1
Capture convertible data? NO
------------------------------ ------------------------------------------------

[Scan Summary]

All character type application data remain the same in the new character set

[Data Dictionary Conversion Summary]

Datatype Changeless Convertible Truncation Lossy
--------------------- ---------------- ---------------- ---------------- ----------------
VARCHAR2 0 0 0 0
CHAR 0 0 0 0
LONG 0 0 0 0
CLOB 0 0 0 0
VARRAY 0 0 0 0
--------------------- ---------------- ---------------- ---------------- ----------------
Total 0 0 0 0
Total in percentage 0.000% 0.000% 0.000% 0.000%


[Application Data Conversion Summary]

Datatype Changeless Convertible Truncation Lossy
--------------------- ---------------- ---------------- ---------------- ----------------
VARCHAR2 713 0 0 0
CHAR 23 0 0 0
LONG 0 0 0 0
CLOB 0 0 0 0
VARRAY 0 0 0 0
--------------------- ---------------- ---------------- ---------------- ----------------
Total 736 0 0 0
Total in percentage 100.000% 0.000% 0.000% 0.000%

[Distribution of Convertible, Truncated and Lossy Data by Table]

USER.TABLE Convertible Truncation Lossy
-------------------------------------------------- ---------------- ---------------- ----------------
-------------------------------------------------- ---------------- ---------------- ----------------

[Distribution of Convertible, Truncated and Lossy Data by Column]

USER.TABLE|COLUMN Convertible Truncation Lossy
-------------------------------------------------- ---------------- ---------------- ----------------
-------------------------------------------------- ---------------- ---------------- ----------------

[Indexes to be Rebuilt]

USER.INDEX on USER.TABLE(COLUMN)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

3.最后看看它的帮助说明:

$ csscan -help

Character Set Scanner v2.1 : Release 10.2.0.3.0 - Production on Thu Apr 17 16:40:09 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.


You can let Scanner prompt you for parameters by entering the CSSCAN
command followed by your username/password:

Example: CSSCAN SYSTEM/MANAGER

Or, you can control how Scanner runs by entering the CSSCAN command
followed by various parameters. To specify parameters, you use keywords:

Example: CSSCAN SYSTEM/MANAGER FULL=y TOCHAR=utf8 ARRAY=1024000 PROCESS=3

Keyword Default Prompt Description
---------- ------- ------ -------------------------------------------------
USERID yes username/password
FULL N yes scan entire database
USER yes owner of tables to be scanned
TABLE yes list of tables to scan
COLUMN yes list of columns to scan
EXCLUDE list of tables to exclude from scan
TOCHAR yes new database character set name
FROMCHAR current database character set name
TONCHAR new national character set name
FROMNCHAR current national character set name
ARRAY 1024000 yes size of array fetch buffer
PROCESS 1 yes number of concurrent scan process
MAXBLOCKS split table if block size exceed MAXBLOCKS
CAPTURE N capture convertible data
SUPPRESS maximum number of exceptions logged for each table
FEEDBACK report progress every N rows
BOUNDARIES list of column size boundaries for summary report
LASTRPT N generate report of the last database scan
LOG scan base file name of report files
PARFILE parameter file name
PRESERVE N preserve existing scan results
LCSD N no enable language and character set detection
LCSDDATA LOSSY no define the scope of the detection
HELP N show help screen (this screen)
QUERY N select clause to scan subset of tables or columns
---------- ------- ------ -------------------------------------------------
Scanner terminated successfully.


二、lcsscan

lcsscan用于快速确定指定文本的语言和字符集的基于统计的实用工具。lcsscan的使用相对简单,功能也比较单一。

1.先看看它的帮助说明:

[oracle@oracle ~]$ lcsscan -help


Language and Character Set File Scanner v2.1

(c) Copyright 2003, 2004 Oracle Corporation. All rights reserved.


You can control how LCSSCAN runs by entering the LCSSCAN command
followed by the required parameters. To specify parameters, you use
keywords:

Example: LCSSCAN RESULTS=2 END=1000 FORMAT=HTML FILE=index.html

Keyword Description (Default)
--------------------------------------------------------------------
RESULTS number of language and character set pairs to return (1)
BEGIN beginning byte offset of file (1)
END ending byte offset of file (end of file)
FORMAT file format TEXT, HTML or AUTO detect (TEXT)
FILE name of input file
HELP show help screen (this screen)

FILE就是要扫描的文件,BEGIN和END则指定只扫描文件的部分内容。RESULTS指明要返回几组可用的结果,因为一个文件可能兼容于多种字符集。FORMAT指明文件的类型。

2.使用举例:

[oracle@oracle bdump]$ lcsscan file=alert_test.log


Language and Character Set File Scanner v2.1

(c) Copyright 2003, 2004 Oracle Corporation. All rights reserved.


alert_test.log: ENGLISH US7ASCII;


三、lbuilder

关于oracle的全球化支持,10g提供了一个非常专业的强大的工具Local Builder--lbuilder,它存放在$ORACLE_HOME/nls/lbuilder/文件夹下。lbuilder是一个图形界面的工具,它能够通过自定义语言、区域、字符集以及语言排序等来实现特定的全球化环境。

from:http://blog.csdn.net/randyamor/archive/2008/04/19/2308074.aspx

分享到:
评论

相关推荐

    两个软件奥mysql转oracle oracle转mysql

    Convert Mysql to Oracle功能特点 可能转换所有的Mysql字段类型 支持所有版本的Mysql 可以将数据合并到已经存在的ORACLE表中 非常容易使用的向导模式 支持所有版本的Mysql字符集 对超大数据表的导出进行了优化处理

    Oracle数据库恢复工具Oracle Database Unloader(ODU)3.09

    支持多种字符集之间的转换,能够正确的转换CLOB、NCLOB、NVARCHAR2列类型的数据到指定的字符集。 ODU全面支持64位系统,支持超过4G大小的数据文件。 支持复制操作系统命令不能复制的坏文件 模拟oracle的dump块...

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

     EXP_FULL_DATABASE, IMP_FULL_DATABASE这两个角色用于数据导入导出工具的使用。  自定义角色 Oracle建议我们自定义自己的角色,使我们更加灵活方便去管理用户  创建角色 SQL> create role admin;  授权给...

    oracle详解

    导入/导出是ORACLE幸存的最古老的两个命令行工具,其实我从来不认为Exp/Imp是一种好的备份方式,正确的说法是Exp/Imp只能是一个好的转储工具,特别是在小型数据库的转储,表空间的迁移,表的抽取,检测逻辑和物理...

    本机不安装ORACLE直接连接服务器上的ORACLE

    Instant client Package - Basic Lite: 只包含英语错误信息, 只支持unicode, ascii, 西欧字符集. Instant client Package - JDBC Supplement 为jdbc增加了xa, 国际化和RowSet操作. Instant Client Package - SQL ...

    Oracle SQL高级编程(资深Oracle专家力作,OakTable团队推荐)--随书源代码

     Oracle 数据库中的SQL是当今市场上功能最强大的SQL实现之一,而本书全面展示了这一工具的威力。如何才能让更多人有效地学习和掌握SQL呢?Karen Morton及其团队在本书中提供了专业的方案:先掌握语言特性,再学习...

    ORACLE11G宝典.rar 是光盘里面的内容,书太厚咧没法影印啊

     4.2.2 语言字符集、常用符号  4.2.3 常量与变量  4.2.4 数据类型  4.2.5 集合API方法  4.3 流程控制  4.3.1条件控制  4.3.2 循环控制  4.3.3 顺序控制  4.4 游标  4.4.1显式游标  4.4.2 隐式...

    赤兔Oracle数据库恢复软件 v11.6.zip

    27.支持多种字符集之间的转换,能够正确的转换CLOB、NCLOB、NVARCHAR2列类型的数据到指定的字符集。 28.自动检测数据文件的表空间号和文件号 29.导出的数据格式包括纯文本和DMP文件两种。以纯文本导出时,能够自动...

    Direct Oracle Access v4.1.3 bcb6

    使用 Direct Oracle Access,应用程序可以充分利用两个产品的优势。 主要特性: 高性能 ——Oracle的性能特性对于在线业务和批处理程序非常有用。通过Direct Oracle Access,能够直接访问Oracle接口,从而使得标准...

    Oracle9i的init.ora参数中文说明

    在客户机和服务器上使用同一字符集时, 应以该字符集所定义的字符来衡量字符串。现有的列将不受影响。 值范围: BYTE 或 CHAR。 默认值: nls_length_semantics 的数据库字符集的字符所使用的度量单位。BYTE。 nls_...

    OCPOCA认证考试指南全册:Oracle Database 11g(1Z0-051,1Z0-052,1Z0-053)--详细书签版(第2/2部分)

    2.1 了解Oracle数据库管理工具 44 2.1.1 Oracle Universal Installer 44 2.1.2 创建数据库和升级数据库的工具 48 2.1.3 发送即席SQL的工具:SQL*Plus和SQL Developer 48 2.1.4 Oracle Enterprise Manager 52 ...

    Oracle数据库实验操作

    数据库字符集 162 实验81:配置国家语言支持 163 元数据 165 实验82:提取元数据dbms_metedata 165 第四部分数据库的网络配置 168 实验83:配置监听 168 实验84:客户端的网络配置 169 实验85:数据库共享连接的配置...

    oracle安装及备份

    oracle用java编写,SQLPLUS.EXE、EXP.EXE、IMP.EXE这两个文件有可能是被包装后的类文件。 SQLPLUS.EXE调用EXP.EXE、IMP.EXE所包裹的类,完成导入导出功能。 下面介绍的是导入导出的实例。 数据导出: 1 将数据库TEST...

    OCPOCA认证考试指南全册:Oracle Database 11g(1Z0-051,1Z0-052,1Z0-053)--详细书签版(第1/2部分)

    2.1 了解Oracle数据库管理工具 44 2.1.1 Oracle Universal Installer 44 2.1.2 创建数据库和升级数据库的工具 48 2.1.3 发送即席SQL的工具:SQL*Plus和SQL Developer 48 2.1.4 Oracle Enterprise Manager 52 ...

    VC++6.0核心编程源码.rar

    Visual studio还配有一个小的实用程序,称为Error Lookup。你可以使用Error Lookup将错误代码的号码转换成它的文本描述。 见P7的Error Lookup插图 如果我在我编写的应用程序中发现一个错误,我可能想要向用户显示...

    Navicat Premium 11.0.17简体中文注册版.rar

    可以在源数据库和目标数据库之间传输数据,也可在源数据库和目标数据库之间进行数据同步,同步数据结构,比较两个数据库之间的的表、主键、外键、索引、触发器及字符集、比对自动递增值及分割区,比对视图、函数、...

    JAVA上百实例源码以及开源项目源代码

     基于JAVA的UDP服务器模型源代码,内含UDP服务器端模型和UDP客户端模型两个小程序,向JAVA初学者演示UDP C/S结构的原理。 简单聊天软件CS模式 2个目标文件 一个简单的CS模式的聊天软件,用socket实现,比较简单。 ...

Global site tag (gtag.js) - Google Analytics