Sqlldr

Sqlldr 
1)import /etc/passwd 
1@@@@usage
SQL> conn /as sysdba;
SQL> create directory dir60 as '/u01/app/oracle/directory/orcl/dir60';
SQL> grant  read,write on directory dir60 to hr;
 
@@@
[oracle@station60 dir60]$ cp /etc/passwd  passwd.dat
SQL> create table t04218_passwd(os_username varchar2(20),
                                os_passwd varchar2(20),
                                os_uid number(5),
                                os_gid number(5),
                                user_comment varchar2(100),
                                user_home varchar2(100),
                                shell varchar2(30)); 
 
@@@
[oracle@station60 dir60]$ cat ospasswd.ctl 
LOAD DATA 
INFILE 'passwd.dat'
INTO TABLE t04218_passwd 
FIELDS TERMINATED BY ':'
( os_username char,
  os_passwd char,
  os_uid integer external,
  os_gid integer external,
  user_comment char,
  user_home char,
  shell char)
 
@@@
[oracle@station60 dir60]$ sqlldr hr/hr control=ospasswd.ctl 
..................
 
@@@cat log to check result.
[oracle@station60 dir60]$ cat ospasswd.log 
.......................
Table T04218_PASSWD:
  40 Rows successfully loaded.
  1 Row 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.
.................
 
[oracle@station60 dir60]$ wc -l passwd.dat 
41 passwd.dat
SQL> select count(*) from T04218_PASSWD;
  COUNT(*)
----------
        40
@@@
[oracle@station60 dir60]$ ls
ospasswd.ctl  ospasswd.log  passwd.bad  passwd.dat
[oracle@station60 dir60]$ cat passwd.bad 
news:x:9:13:news:/etc/news:

你可能感兴趣的:(sqlldr)