[oracle@jumper utl_file]$ more main.sql
set linesize 200
set term off verify off feedback off pagesize 999
set markup html on entmap ON spool on preformat off
spool d:/tables.xls
@d:/get_tables.sql
spool off
exit
2.get_tables.sql脚本:
[oracle@jumper utl_file]$ more get_tables.sql
select owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables order by 1,2;
3.执行并获得输出:
[oracle@jumper utl_file]$ sqlplus "/ as sysdba" @d:/main.sql
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Apr 25 10:30:11 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
[oracle@jumper utl_file]$ ls -l tables.xls
-rw-r--r-- 1 oracle dba 69539 Apr 25 10:30 tables.xls
[oracle@jumper utl_file]$
1.录入excel 测试表格,test.xls。
2.另存为.csv格式
3.创建sql*loader控制文件test.ctl,内容如下:
Load data
Infile 'c:/test.csv'
insert Into table test Fields terminated by ','(column1,column2,column3,column4,column5)
附:
Sqlldr的函数关键字说明:
Userid --oracle用户名 userid = username/password
Control --控制文件名称 control = ‘e:/insert.ctl’
Log –-日志文件名称 log = ‘e:/insert.log’
Bad --损坏文件名称
Data --data file name
Discard --discard file name
Discardmax --number of discards to allow(默认全部)
Skip --导入时跳过的记录行数(默认0)
Load --导入时导入的记录行数(默认全部)
Errors --允许错误的记录行数(默认50)
ctl文件内容说明:
Load data
Infile ‘e:/test.csv’ --数据源文件名称
Append|insert|replace --append在表后追加,insert插入空表,replace替代原有内容
Into table test --要导入的数据库表名称
[when id = id_memo] --过滤条件
Fields terminated by X’09’ --字段分隔符
(id,name,telphone) --字段名称列表