- 浏览: 61525 次
- 性别:
- 来自: 宁波
最新评论
-
Love_洋果子:
楼主写的很好,好几点总结中存在自己的影子.
对测试新手的一些经验谈 -
fromaust:
不错啊。怎么没人顶
Java网络编程 -
aries211:
http://zhanfeng.blog.cnstock.co ...
边走边看之股票收集 -
zhangzhaofeng:
要在经历中学习...
慢慢的经历多了,没有变麻木,反而变得敏感了。。。。。。。。 -
抛出异常的爱:
谁说经历多了就要麻木?
那么鲁先人在叫个什么呢?
经历了有了思 ...
慢慢的经历多了,没有变麻木,反而变得敏感了。。。。。。。。
Overview
To use the Oracle bulk loader, you need a control file, which specifies how data should be loaded into the database; and a data file, which specifies what data should be loaded. You will learn how to create these files in turn.
Creating the Control File
A simple control file has the following form:
LOAD DATA
INFILE <datafile>
APPEND INTO TABLE <tablename>
FIELDS TERMINATED BY '<separator>'
(<list load="" to="" names="" attribute="" all="" of="">)</list></separator></tablename></datafile>
- <datafile></datafile> is the name of the data file. If you did not give a file name extension for <datafile></datafile>, Oracle will assume the default extension ".dat". Therefore, it is a good idea to name every data file with an extension, and specify the complete file name with the extension.
- <tablename> </tablename> is the name of the table to which data will be loaded. Of course, it should have been created already before the bulk load operation.
- The optional keyword APPEND says that data will be appended to <tablename> </tablename> . If APPEND is omitted, the table must be empty before the bulk load operation or else an error will occur.
- <separator></separator> specifies the field separator for your data file. This can be any string. It is a good idea to use a string that you know will never appear in the data, so the separator will not be confused with data fields.
- Finally, list the names of attributes of <tablename> </tablename> that are set by your data file, separated by commas and enclosed in parentheses. This list need not be the complete list of attributes in the actual schema of the table, nor must it be arranged in the same order as the attributes when the table was created -- sqlldr will match attributes to by their names in the table schema. Any attributes unspecified in the list of attributes will be set to NULL.
LOAD DATA
INFILE test.dat
INTO TABLE test
FIELDS TERMINATED BY '|'
(i, s)
Creating the Data File
Each line in the data file specifies one tuple to be loaded into
<tablename>
</tablename>
. It lists, in order, values for the attributes in the list specified in the control file, separated by <separator></separator>. As a concrete example, test.dat might look like:
1|fooRecall that the attribute list of test specified in test.ctl is (i, s), where i has the type int, and s has the type char(10). As the result of loading test.dat, the following tuples are inserted into test:
2|bar
3| baz
(1, 'foo')
(2, 'bar')
(3, ' baz')
Some Notes of Warning
- Note that the third line of test.dat has a blank after "|". This blank is not ignored by the loader. The value to be loaded for attribute s is ' baz', a four-character string with a leading blank. It is a common mistake to assume that 'baz', a three-character string with no leading blank, will be loaded instead. This can lead to some very frustrating problems that you will not notice until you try to query your loaded data, because ' baz' and 'baz' are different strings.
- Oracle literally considers every single line to be one tuple, even an empty line! When it tries to load data from an empty line, however, an error would occur and the tuple will be rejected. Some text editors love to add multiple newlines to the end of a file; if you see any strange errors in your .log file about tuples with all NULL columns, this may be the cause. It shouldn't affect other tuples loaded.
- If you are using a Microsoft text editor, such as MSWord, you will find that Bill Gates believes in ending lines with the sequence <cr> (carriage return) <lf> (line feed). The UNIX world uses only <lf>, so each <cr> becomes ^M, the last character of strings in your load file. That makes it impossible for you ever to match a stored string in an SQL query. Here's how you remove ^M symbols from your file. Let's say the file with ^M symbols is bad_myRel.dat. Then the following command will create myRel.dat without ^M symbols: </cr></lf></lf></cr>
cat bad_myRel.dat | tr -d '\015' > myRel.dat
If you're an emacs fan, type in the following sequence to modify your current buffer:
ESC-x replace-string CTRL-q CTRL-m ENTER ENTER
Loading Your Datasqlldr <yourname> control=<ctlfile> log=<logfile> bad=<badfile></badfile></logfile></ctlfile></yourname>
Everything but sqlldr is optional -- you will be prompted for your username, password, and control file. <ctlfile></ctlfile> is the name of the control file. If no file name extension is provided, sqlldr will assume the default extension ".ctl". The name of the data file is not needed on the command line because it is specified within the control file. You may designate <logfile></logfile> as the log file. If no file name extension is provided, ".log" will be assumed. sqlldr will fill the log file with relevant information about the bulk load operation, such as the number of tuples loaded, and a description of errors that may have occurred. Finally, you may designate <badfile></badfile> as the file where bad tuples (any tuples for which an error occurs on an attempt to load them) are recorded (if they occur). Again, if no file extension is specified, Oracle uses ".bad". If no log file or bad file are specified, sqlldr will use the name of the control file with the .log and .bad extensions, respectively.As a concrete example, if sally wishes to run the control file test.ctl and have the log output stored in test.log, then she should type
sqlldr sally control=test.ctl log=test.log
Reminder: Before you run any Oracle commands such as sqlldr and sqlplus, make sure you have already set up the correct environment by sourcing /afs/ir/class/cs145/all.env (see Getting Started With Oracle).
Loading Without a Separate Data FileLOAD DATA
The trick is to specify "*" as the name of the data file, and use BEGINDATA to start the data section in the control file.
INFILE *
INTO TABLE test
FIELDS TERMINATED BY '|'
(i, s)
BEGINDATA
1|foo
2|bar
3| baz
Loading DATE DataCREATE TABLE foo (
In the control file, when you describe the attributes of foo being loaded, you follow the attribute d by its type DATE and a date mask. A date mask specifies the format your date data will use. It is a quoted string with the following conventions:
i int,
d date
);- Sequences of d, m, or y, denote fields in your data that will be interpreted as days, months, years, respectively. As with almost all of SQL, capitals are equally acceptable, e.g., MM is a month field.
- The lengths of these fields specify the maximum lengths for the corresponding values in your data. However, the data can be shorter.
- Other characters, such as dash, are treated literally, and must appear in your data if you put them in the mask.
LOAD DATA
Notice that, as illustrated by the second tuple above, a field can be shorter than the corresponding field in the date mask. The punctuation "-" tells the loader that the day and month fields of the second tuple terminate early.
INFILE *
INTO TABLE foo
FIELDS TERMINATED BY '|'
(i, d DATE 'dd-mm-yyyy')
BEGINDATA
1|01-01-1990
2|4-1-1998
Loading Long StringsCREATE TABLE foo (x VARCHAR(4000));
Then a sample control file should look like:
LOAD DATA
Note that the declaration takes the form CHAR(n) regardless of whether the field type was declared as CHAR or VARCHAR.
INFILE <datafile>
INTO TABLE foo
FIELDS TERMINATED BY '|'
(x CHAR(4000))</datafile>
Entering NULL Values3||5
would result in inserting the following tuples in the relation:
|2|4
1||6
||7(3, NULL, 5)
Keep in mind that any primary keys or other constraints requiring that values be non-NULL will reject tuples for which those attributes are unspecified.
(NULL, 2, 4)
(1, NULL, 6)
(NULL, NULL, 7)Note:If the final field in a given row of your data file will be unspecified (NULL), you have to include the line TRAILING NULLCOLS after the FIELDS TERMINATED BY line in your control file, otherwise sqlldr will reject that tuple. sqlldr will also reject a tuple whose columns are all set to NULL in the data file.
If you do not wish to enter values for any row of a given column, you can, as mentioned above, leave that column out of the attribute list altogether.
发表评论
-
RMAN简明使用手册
2010-04-29 09:54 862RMAN简明使用手册 〇:背景信息 使用手册基于ORACLE ... -
Using the Oracle Bulk Loader-1
2007-11-28 18:01 1733Using the Bulk Loader in ORACLE ... -
Java网络编程
2007-01-08 16:58 17938.1 网络编程基本概念,TCP/IP协议简介<o:p& ... -
jsp如何连接数据库!
2006-12-29 13:11 1701一、jsp连接Oracle8/8i/9i数 ... -
精妙SQL语句介绍
2006-12-29 13:07 1152精妙SQL语句介绍 如何从一位菜鸟蜕变成为高手,灵活使用的SQ ... -
漫谈软件测试工程师的角色定位(资料)
2006-11-29 13:56 1398经理、系统分析师、程 ... -
注意你的英语礼貌用语
2006-11-22 09:43 2889是不是你说的话常常会引起误会呢?你是否不能获得请求的回复呢?如 ... -
QA,QC,Testing
2006-11-18 18:33 1477其实搞测试好像也不错哦,720行,行行出状元嘛 看了一些关于测 ...
相关推荐
2. 版本信息: 提到的版本是Oracle WebCenter Portal 12c (**.*.*.*.0),这是一个在2019年9月发布的版本。文档编号为E95539-01,这通常用来标识特定的文档或知识库条目。 3. 版权声明: 文档开头包含版权声明,明确...
1. Implement a blurring filter using the equation (5.6-11,数字图像处理(第三版))in textbook, and blur the test image ‘book_cover.jpg’ using parameters a=b=0.1 and T=1. (20%) 2. Add Gaussian noise ...
Read-the-indicator-value-using-Deep-Learning-main
altera软件下载时在Quartus上软件的利用方法是谈论的。请参考硬件原理图。
ORACLE-BASE - Oracle Database 11g Release 2 RAC On Linux Using VMware Server 2
本教程“Creating and Using Oracle Solaris Zones-216”是为帮助用户理解和充分利用这一技术而编写的。 首先,了解Oracle Solaris Zones的核心概念是至关重要的。每个Zone都是一个独立的计算环境,拥有自己的文件...
Course Objectives 1-2 Suggested Schedule 1-3 Lesson Objectives 1-4 Oracle Products and Services 1-5 Oracle Database 10g: “g” Stands for Grid 1-6 Oracle Database Architecture 1-8 Database Structures ...
Thoroughly updated for Oracle Database 11g Release 2, this edition reveals new PL/SQL features and provides extensive code samples, ranging from simple examples to complex and complete applications, ...
Objectives 3-2 Review of Group Functions 3-3 Review of the GROUP BY Clause 3-4 Review of the HAVING Clause 3-5 GROUP BY with ROLLUP and CUBE Operators 3-6 ROLLUP Operator 3-7 ROLLUP Operator Example 3...
官方资料:白皮书[英文]Oracle Database 1 2c Multitenant Snapshot Clones Using Oracle CloudFS Oracle Multitenant Architecture.;Oracle CloudFS Architecture;Oracle ASM Dynamic Volume Manager (ADVM);Oracle...
注意打開需要密碼:jmclurkin@rice.edu
综上所述,"Oracle 10g RAC On Windows 2003 Using VMware Server"涵盖了虚拟化技术、Windows集群服务、Oracle RAC架构、共享存储解决方案以及集群的管理和维护等多个IT领域的知识点。通过这样的部署,用户可以构建...
4. **Les04-Interacting with the Oracle Database Server**:这部分将深入解释如何通过PL/SQL与Oracle服务器进行交互,包括游标(CURSOR)的使用,以及如何执行动态SQL。 5. **Les05-Writing Control Structures**...