CASE11

1. SQL脚本

[oracle@node3 ulcase]$ cat ulcase11.sql

set termout off

rem host write sys$output "Building demonstration tables for case study 11.  Please wait"

drop table emp;

create table emp
(empno number(4) not null,
ename char(10),
job char(9),
mgr number(4),
hiredate date,
sal number(7,2),
comm number(7,2),
deptno number(2),
projno number,
loadseq number); exit

2. 控制文件

[oracle@node3 ulcase]$ cat ulcase11.ctl

-- Copyright (c) 1991, 2004 Oracle.  All rights reserved.
-- NAME
-- ulcase11.ctl - SQL*Loader Case Study 11: Load Data in the Unicode
-- Character Set UTF-16
--
-- DESCRIPTION
-- This case study demonstrates the following:
-- Using SQL*Loader to load data in the Unicode character set, UTF16.
--
-- Using SQL*Loader to load data in a fixed-width, multibyte character set.
--
-- Using character-length semantics.
--
-- Using SQL*Loader to load data in little-endian byte order. SQL*Loader
-- checks the byte order of the system on which it is running. If necessary,
-- SQL*Loader swaps the byte order of the data to ensure that any
-- byte-order-dependent data is correctly loaded.
--
-- TO RUN THIS CASE STUDY:
-- 1. Before executing this control file, log in to SQL*Plus as
-- scott/tiger. Enter @ulcase11 to execute the SQL script for
-- this case study. This prepares and populates tables and
-- then returns you to the system prompt.
--
-- 2. At the system prompt, invoke the case study as follows:
-- sqlldr USERID=scott/tiger CONTROL=ulcase11.ctl LOG=ulcase11.log
--
-- NOTES ABOUT THIS CONTROL FILE
--
-- The character set specified with the CHARACTERSET keyword is UTF16.
-- SQL*Loader will convert the data from the UTF16 character set to
-- the database character set. Because UTF16 is specified as the
-- character set, character-length semantics are used for the load.
--
-- BYTEORDER LITTLE tells SQL*Loader that the data in the datafile is
-- in little-endian byte order. SQL*Loader checks the byte order of the
-- system on which it is running to determine if any byte-swapping is
-- necessary. In this example, all the character data in UTF16 is
-- byte-order dependent.
--
-- The TERMINATED BY and OPTIONALLY ENCLOSED BY clauses both specify
-- hexadecimal strings. The X'002c' is the encoding for a comma (,) in
-- UTF-16 big-endian format. The X'0022' is the encoding for a double
-- quotation mark (") in big-endian format. Because the datafile is in
-- little-endian format, SQL*Loader swaps the bytes before checking for
-- a match. If these clauses were specified as character strings instead
-- of hexadecimal strings, SQL*Loader would convert the strings to the
-- datafile character set (UTF16) and byte-swap as needed before checking
-- for a match.
--
-- Because character-length semantics are used, the maximum length for
-- the empno, hiredate, and deptno fields is interpreted as characters,
-- not bytes.
--
-- The TERMINATED BY clause for the deptno field is specified using the
-- character string ":". SQL*Loader converts the string to the datafile
-- character set (UTF16) and byte-swaps as needed before checking for a match. LOAD DATA
CHARACTERSET utf16
BYTEORDER little
INFILE ulcase11.dat
REPLACE INTO TABLE EMP
FIELDS TERMINATED BY X'002c' OPTIONALLY ENCLOSED BY X''
(empno integer external (5), ename, job, mgr,
hiredate DATE(20) "DD-Month-YYYY",
sal, comm,
deptno CHAR(5) TERMINATED BY ":",
projno,
loadseq SEQUENCE(MAX,1) )

3. 数据文件

数据文件因为是UTF16编码,在文本文件中显示为乱码,在这里不贴出。

执行后结果:

[oracle@node3 ulcase]$ sqlplus scott/tiger @ulcase11.sql

[oracle@node3 ulcase]$ sqlldr userid=scott/tiger control=ulcase11.ctl

SQL> select * from emp;

EMPNO ENAME  JOB       MGR HIREDATE       SAL    COMM  DEPTNO PROJNO    LOADSEQ
----- ------ --------- ----- --------- ------- ----- ------ ------ ----------
7782 Clark Manager 7839 09-JUN-81 2573 10 101 1 7839 King President 17-NOV-81 5500 10 102 2 7934 Miller Clerk 7782 23-JAN-82 920 10 102 3 7566 Jones Manager 7839 02-APR-81 3124 20 101 4 7499 Allen Salesman 7698 20-FEB-81 1600 300 30 103 5 7654 Martin Salesman 7698 28-SEP-81 1313 1400 30 103 6 7658 Chan Analyst 7566 03-MAY-82 3450 20 101 7 7 rows selected.

查看一下日志文件:

[oracle@node3 ulcase]$ cat ulcase11.log

SQL*Loader: Release 11.2.0.1.0 - Production on Fri Sep 19 04:13:59 2014

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

Control File:   ulcase11.ctl
Character Set utf16 specified for all input.
Using character length semantics.
Byteorder little endian specified. Data File: ulcase11.dat
Bad File: ulcase11.bad
Discard File: none specified (Allow all discards) Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional Table EMP, loaded from every logical record.
Insert option in effect for this table: REPLACE Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
EMPNO FIRST 10 , O(") CHARACTER
ENAME NEXT * , O(") CHARACTER
JOB NEXT * , O(") CHARACTER
MGR NEXT * , O(") CHARACTER
HIREDATE NEXT 40 , O(") DATE DD-Month-YYYY
SAL NEXT * , O(") CHARACTER
COMM NEXT * , O(") CHARACTER
DEPTNO NEXT 10 : O(") CHARACTER
PROJNO NEXT * , O(") CHARACTER
LOADSEQ SEQUENCE (MAX, 1) Table EMP:
7 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null. Space allocated for bind array: 104768 bytes(64 rows)
Read buffer bytes: 1048576 Total logical records skipped: 0
Total logical records read: 7
Total logical records rejected: 0
Total logical records discarded: 0 Run began on Fri Sep 19 04:13:59 2014
Run ended on Fri Sep 19 04:13:59 2014 Elapsed time was: 00:00:00.41
CPU time was: 00:00:00.24

总结:在本例中

1> CHARACTERSET utf16指数据文件的字符集是utf16

2> BYTEORDER little指the data in the datafile is in little-endian byte order。

SQL*Loader之CASE11的更多相关文章

  1. SQL*LOADER错误总结

    在使用SQL*LOADER装载数据时,由于平面文件的多样化和数据格式问题总会遇到形形色色的一些小问题,下面是工作中累积.整理记录的遇到的一些形形色色错误.希望能对大家有些用处.(今天突然看到自己以前整 ...

  2. Bulkcopy对应的实现是Oracle的SQL*LOADER,期间造成Index Unusable,并且last_ddl_time上是不体现的

    部分项目反馈系统整体突然变慢,经查询发现一个系统核心的大数据表的索引状态全部是Unusable. 导致索引失效的直接原因:当某些操作导致数据的rowid改变,索引就会完全失效. 那什么时候会导致row ...

  3. SQL*Loader之CASE10

    CASE10 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase10.sql rem host write sys$output "Building dem ...

  4. SQL*Loader之CASE9

    CASE9 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase9.sql set termout off rem host write sys$output &quo ...

  5. SQL*Loader之CASE8

    CASE8 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase8.sql set termout off rem host write sys$output &quo ...

  6. SQL*Loader之CASE7

    CASE7 1. SQL脚本 case7包含两个SQL脚本,一个是删除脚本ulcase7e.sql,一个是创建脚本ulcase7s.sql [oracle@node3 ulcase]$ cat ulc ...

  7. SQL*Loader之CASE6

    CASE6 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase6.sql set termout off rem host write sys$output &quo ...

  8. SQL*Loader之CASE5

    CASE5 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase5.sql set termout off rem host write sys$output &quo ...

  9. SQL*Loader之CASE4

    CASE4 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase4.sql set termout off rem host write sys$output &quo ...

随机推荐

  1. .NET相关操作其他文件的小程序(系列文章)

    平时自诩为使用.NET做开发,但是实际上从一开始学习C#直到现在除了做个几个不登大雅之堂的小网站,做过几个winform程序和几个控制台应用程序,真的没有踏踏实实地用.NET开发过某些属于自己的东西. ...

  2. iOS开发--Block

    iOS开发--Block 1.什么是Block,block 的作用 ui开发和网络常见功能实现回调,按钮的事件处理方法是回调方法以及网络下载后的回调处理 (1)按钮 target-action   一 ...

  3. oracle表空间不足时的处理方法

    由于数据文件路径下的空间不足或表空间不足时,需要更换或扩展或新增表空间时,以下简单介绍下几种处理方式(数据文件/opt/oracle/oradata/testdb.dbf,原大小为100M) 一.扩大 ...

  4. 持续集成(CI)相关的一些工具,后续补充。。。。

    持续集成的目标:使项目开发更加便捷 1.make工具 最原始的工具,负责组织构建的过程,即指挥编译器如何编译,连接器如何链接,最后生成一个可用文件. 2.Ant工具 Ant是一个构建工具,它只有一个配 ...

  5. 团队spring会议1

    一.我们在近期进行了第一次计划会议,会议过程大致如下: 1.确定所做项目的方向: 2.将调查问卷的结果进行统计,做了需求分析,大致了解了用户的想法: 3.确定了团队计划backlog: 4.将任务进行 ...

  6. ubuntu共享文件配置

    目标:实现windows和linux混合组成的操作 系统中可以共享文件,并可以通过机器名互相访问 安装文件共享服务 0.更改本机主机名,修改 /etc/hostname文件和/etc/hosts文件中 ...

  7. 解决VS2008 开发Windows Mobile 项目生成速度慢的问题(转)

    最近用VS2008开发Windows Mobile程序,使用C#..NET Compact Framework,发现项目生成速度比较慢.用VS2008打开项目后,开始一段时间生成速度还能忍受,时间一长 ...

  8. ASP.NET 5 入门 (3) – Logging

    ASP.NET 5 理解和入门 建立和开发ASP.NET 5 项目 使用自定义配置文件 ASP.NET 5 入门 (3) – Logging 前几天就关注到汤姆大叔的相关文档: 解读ASP.NET 5 ...

  9. 获取机器安装.NET版本的几种方式

    当调查应用程序问题时,通常需要先确认目标机器所安装的 .NET Framework 的版本.可以通过如下方式来确认版本号: 通过控制面板安装程序查询 通过查询注册表获取版本信息 通过查看安装目录获取版 ...

  10. JavaScript开发原生App模式能否突出重围?

    移动应用制作的第三方服务市场已经被瓜分得差不多了,对于刚起步的中小企业来说,这些公司的 IT 部门人员比较熟悉的是 Appcan ,但随着互联网公司对 App 开发的需求持续升温,也有不少后来的闯入者 ...