Haiyanliang’s Weblog

export table in mysql into Oracle

Posted in Uncategorized by haiyanliang on January 24, 2010

mysql> select * into outfile ‘/tmp/result.csv’ fields TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”‘
-> ESCAPED by ‘\\’ lines terminated by ‘\n’ from movie where 1;
Query OK, 1321 rows affected (0.01 sec)

select * into outfile ‘/tmp/movie.txt’ fields TERMINATED BY ‘||||’ terminated by ‘\n’ from movie where 1;

select * into outfile ‘/tmp/movie.txt’ fields TERMINATED BY ‘||||’ ESCAPED by ‘\\’ lines terminated by ‘\n’ from movie where 1;

Create External Table in Oracle

CREATE TABLE ext_tab (
empno  CHAR(4),
ename  CHAR(20),
job    CHAR(20),
deptno CHAR(2))
ORGANIZATION EXTERNAL (
TYPE oracle_loader
DEFAULT DIRECTORY ext
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
BADFILE ‘bad_%a_%p.bad’
LOGFILE ‘log_%a_%p.log’
FIELDS TERMINATED BY ‘,’
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
(empno, ename, job, deptno))
LOCATION (‘demo1.dat’)
)
PARALLEL
REJECT LIMIT 0
NOMONITORING;

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.