我的编程空间,编程开发者的网络收藏夹
学习永远不晚

Oracle工具——csscan

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

Oracle工具——csscan

转载自:http://blog.itpub.net/4227/viewspace-706635/

工具csscan用于检查从一个字符集转换到另一个字符集,数据库中的数据是否会产生丢失、截断等现象。

 

 

这个工具很早就出现了,不过由于长久以来牵制到字符集转换的工作不是很多,因此对于这个工具没什么研究,这次需要将ZHS16GBK转换到AL32UTF8,尝试了一下csscan的功能,发现这个工具还是很方便的。

[oracle@dbserver1 bin]$ csscan userid=thams/thams table=libfile722 tochar=AL32UTF8 log=/home/oracle/scan_722

Character Set Scanner v2.2 : Release 11.2.0.2.0 - Production on Wed Aug 31 10:54:15 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

CSS-00127: user thams does not have DBA privilege

Scanner terminated unsuccessfully.

错误信息很明显,连接用户不是DBA角色,如果用system用户连接进行这个命令:

[oracle@dbserver1 bin]$ csscan userid=system/oracle table=thams.libfile722 tochar=AL32UTF8 log=/home/oracle/scan_722

Character Set Scanner v2.2 : Release 11.2.0.2.0 - Production on Wed Aug 31 10:54:45 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

CSS-00107: Character set migration utility schema not installed

Scanner terminated unsuccessfully.

导致这个错误是由于CSSCAN工具需要在数据库中建立一个CSMIG用户:

[oracle@dbserver1 bin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Wed Aug 31 10:57:28 2011

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> @?/rdbms/admin/csminst

User created.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

Grant succeeded.

User altered.

1 row created.

1 row updated.

Table created.
.
.
.
View created.

View created.

View created.

View created.

Grant succeeded.

Grant succeeded.

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

[oracle@dbserver1 bin]$ csscan userid=system/oracle table=thams.libfile722 tochar=AL32UTF8 log=/home/oracle/scan_722

Character Set Scanner v2.2 : Release 11.2.0.2.0 - Production on Wed Aug 31 10:59:35 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

Enter array fetch buffer size: 1024000 > 4096000

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

Enumerating table to scan...

. process 1 scanning THAMS.LIBFILE722[AAAP2KAAAAAB7XYAAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.

调用csminst.sql脚本创建辅助用户和对象后,再次运行csscan工具,对表中数据进行转换前的扫描。

工具csscan的调用有命令行方式,和交互两种,当命令行没有提供足够的参数,工具会以交互方式获取其他参数。

操作完成后,可以检查对应的日志信息:

[oracle@dbserver1 bin]$ more /home/oracle/scan_722.err 
Database Scan Individual Exception Report

[Database Scan Parameters]

Parameter                      Value                                           
------------------------------ ------------------------------------------------
CSSCAN Version                 v2.1                                            
Instance Name                  fhacdb1                                         
Database Version               11.2.0.2.0                                      
Scan type                      Selective tables                                
Scan CHAR data?                YES                                             
Database character set         ZHS16GBK                                        
FROMCHAR                       ZHS16GBK                                        
TOCHAR                         AL32UTF8                                        
Scan NCHAR data?               NO                                              
Array fetch buffer size        4096000                                         
Number of processes                                                          
Capture convertible data?      NO                                              
------------------------------ ------------------------------------------------

[Data Dictionary individual exceptions]

[Application data individual exceptions]

User  : THAMS
Table : LIBFILE722
Column: F4
Type  : VARCHAR2(42)
Number of Exceptions         : 1         
Max Post Conversion Data Size: 45       

ROWID              Exception Type      Size Cell Data(first 30 bytes)     
------------------ ------------------ ----- ------------------------------
AAAP2KAAAAAB+u0AAE exceed column size    45 巡视台湾兼理学政陕西道监察御史
------------------ ------------------ ----- ------------------------------

[oracle@dbserver1 bin]$ more /home/oracle/scan_722.out

Character Set Scanner v2.2 : Release 11.2.0.2.0 - Production on Wed Aug 31 10:59:35 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

Enter array fetch buffer size: 1024000 > 
Enter number of scan processes to utilize(1..64): 1 > 
Enumerating table to scan...

. process 1 scanning THAMS.LIBFILE722[AAAP2KAAAAAB7XYAAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.
[oracle@dbserver1 bin]$ more /home/oracle/scan_722.txt 
Database Scan Summary Report

Time Started  : 2011-08-31 10:59:48
Time Completed: 2011-08-31 10:59:50

Process ID         Time Started       Time Completed
---------- -------------------- --------------------
          2011-08-31 10:59:49  2011-08-31 10:59:49
---------- -------------------- --------------------

[Database Size]

Tablespace                           Used            Free           Total       Expansion
------------------------- --------------- --------------- --------------- ---------------
SYSTEM                            581.81M         118.19M         700.00M            .00K
SYSAUX                            521.38M          78.63M         600.00M            .00K
UNDOTBS1                            7.44M      20,699.56M      20,707.00M            .00K
TEMP                                 .00K            .00K            .00K            .00K
USERS                           1,930.38M         139.88M       2,070.25M            .00K
LOB_AU2M                        8,176.13M   1,937,423.88M   1,945,600.00M         212.00K
LOB_AU8M                       10,074.69M     501,925.31M     512,000.00M            .00K
DATA_ARCHIVE                    5,332.06M   1,018,667.94M   1,024,000.00M            .00K
LOB_AU32M                       4,772.38M     507,227.63M     512,000.00M            .00K
LOB_AU64M                       4,548.38M     507,451.63M     512,000.00M            .00K
------------------------- --------------- --------------- --------------- ---------------
Total                          35,944.63M   4,493,732.63M   4,529,677.25M         212.00K

[Database Scan Parameters]

Parameter                      Value                                           
------------------------------ ------------------------------------------------
CSSCAN Version                 v2.1                                            
Instance Name                  fhacdb1                                         
Database Version               11.2.0.2.0                                      
Scan type                      Selective tables                                
Scan CHAR data?                YES                                             
Database character set         ZHS16GBK                                        
FROMCHAR                       ZHS16GBK                                        
TOCHAR                         AL32UTF8                                        
Scan NCHAR data?               NO                                              
Array fetch buffer size        4096000                                         
Number of processes                                                          
Capture convertible data?      NO                                              
------------------------------ ------------------------------------------------

[Scan Summary]

Some character type application data are not convertible to the new character set

[Data Dictionary Conversion Summary]

Data Dictionary Tables:

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

XML CSX Dictionary Tables:

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

[Application Data Conversion Summary]

Datatype                    Changeless      Convertible       Truncation            Lossy
--------------------- ---------------- ---------------- ---------------- ----------------
VARCHAR2                       222,683           28,308                               0
CHAR                                                                              0
LONG                                                                              0
VARRAY                                                                            0
--------------------- ---------------- ---------------- ---------------- ----------------
Total                          222,683           28,308                               0
Total in percentage             88.721%          11.278%           0.000%           0.000%

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

Data Dictionary Tables:

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

XML CSX Dictionary Tables:

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

Application Data:

USER.TABLE                                    Convertible       Truncation            Lossy
---------------------------------------- ---------------- ---------------- ----------------
THAMS.LIBFILE722                                   28,308                               0
---------------------------------------- ---------------- ---------------- ----------------

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

Data Dictionary Tables:

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

XML CSX Dictionary Tables:

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

Application Data:

USER.TABLE|COLUMN                             Convertible       Truncation            Lossy
---------------------------------------- ---------------- ---------------- ----------------
THAMS.LIBFILE722|F11                                4,648                               0
THAMS.LIBFILE722|F2                                 4,643                               0
THAMS.LIBFILE722|F3                                 4,648                               0
THAMS.LIBFILE722|F46                                  222                               0
THAMS.LIBFILE722|F6                                 4,312                               0
THAMS.LIBFILE722|F7                                   565                               0
THAMS.LIBFILE722|TITLE                              4,642                               0
---------------------------------------- ---------------- ---------------- ---------------

[Indexes to be Rebuilt]

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

工具csscan会生成三个日志,一个err记录错误信息,比如这个例子中,一个列的长度需要变长,否则无法容纳数据长度的扩展;一个log记录操作步骤;而txt则是最终的汇总信息。

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

Oracle工具——csscan

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

2024-04-02

ORACLE工具之使用SQLPLUS

SQL*Plus 是 ORACLE 数据库的命令行工具,它允许用户通过命令行界面与数据库进行交互,并执行 SQL 语句。以下是使用 SQL*Plus 的一些常用操作:1. 连接到数据库:在命令提示符下输入以下命令:```sqlplus us
2023-08-24

Oracle连接池工具类OJDBCUtils

Oraclejdbc.properties driverClassName=oracle.jdbc.driver.OracleDriverurl=jdbc:oracle:thin:@127.0.0.1:1521:orclusername=dbtestpassw
Oracle连接池工具类OJDBCUtils
2018-05-04

oracle开发工具有哪些

oracle 提供了各种开发工具,包括数据库管理工具(sql developer、sql*plus、oracle enterprise manager)、应用程序开发工具(oracle application express、oracle
oracle开发工具有哪些
2024-04-19

编程热搜

目录