数据的装载: SQL*LOADER 外部表 导入/导出 SQL*LOADER: SQL*LOADER是一个Oracle工具,能够将数据从外部数据文件装载到数据库中
数据的装载:
SQL*LOADER:
SQL*LOADER是一个Oracle工具,,能够将数据从外部数据文件装载到数据库中。
运行SQL*LOADER的命令是sqlldr。
Sqlldr的两种使用方式:
1. 只使用一个控制文件,在这个控制文件中包含数据
2. 使用一个控制文件(作为模板) 和一个数据文件
一般采用第二种方式,数据文件可以是 CSV 文件、txt文件或者以其他分割符分隔的。
说明:操作类型 可用以下中的一值:
1) insert --为缺省方式,在数据装载开始时要求表为空
2) append --在表中追加新记录
3) replace --删除旧记录(用 delete from table 语句),替换成新装载的记录
4) truncate --删除旧记录(用 truncate table 语句),替换成新装载的记录
通过spool来制作数据文件:--可以查询帮助文档的示例代码
SQL> spool /u01/app/oracle/test_data_loader/student.txt--开启spool导出数据文件
SQL> select id ||',' || name ||',' || age ||',' || inner_date from student;--导出数据
ID||','||NAME||','||AGE||','||INNER_DATE
--------------------------------------------------------------------------------
1,zhangsan,21,23-JAN-15
2,lisi,22,23-JAN-15
3,wangwu,23,23-JAN-15
SQL> spool off;--关闭
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost test_data_loader]$ cat student.txt--可以查看到导出的数据记录
SQL> select id ||',' || name ||',' || age ||',' || inner_date from student;
ID||','||NAME||','||AGE||','||INNER_DATE
--------------------------------------------------------------------------------
1,zhangsan,21,23-JAN-15
2,lisi,22,23-JAN-15
3,wangwu,23,23-JAN-15
SQL> spool off;
写配置文件:
[oracle@localhost test_data_loader]$ vi student.ctl
[oracle@localhost test_data_loader]$ cat student.ctl
options(skip=4)--表示前面的四行
load data--导入数据
infile 'student.txt'--通过该文件导入数据
into table student--导入的表
insert--执行的是插入操作
fields terminated by ','--记录中的分割符
(
id char,--注意虽然表中是number类型,但是要写char类型
name char,
age char,
inner_date date nullif (inner_date = "null"))
[oracle@localhost test_data_loader]$
既然是insert操作所以:
SQL> truncate table student;--清空表,由于执行的是插入操作
Table truncated.
SQL> select * from student;
no rows selected
执行sqlldr操作:
[oracle@localhost test_data_loader]$ sqlldr hr/hr control= student.ctl log = student.log
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Jan 23 23:11:08 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 4
[oracle@localhost test_data_loader]$ cat student.log
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Jan 23 23:11:08 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Control File: student.ctl
Data File: student.txt
Bad File: student.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 4
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table STUDENT, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
ID FIRST * , CHARACTER
NAME NEXT * , CHARACTER
AGE NEXT * , CHARACTER
INNER_DATE NEXT * , DATE DD-MON-RR
NULL if INNER_DATE = 0X6e756c6c(character 'null')
Record 4: Rejected - Error on table STUDENT, column ID.
Column not found before end of logical record (use TRAILING NULLCOLS)
Table STUDENT:
3 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.
Space allocated for bind array: 66048 bytes(64 rows)
Read buffer bytes: 1048576

이 기사는 MySQL의 Alter Table 문을 사용하여 열 추가/드롭 테이블/열 변경 및 열 데이터 유형 변경을 포함하여 테이블을 수정하는 것에 대해 설명합니다.

기사는 인증서 생성 및 확인을 포함하여 MySQL에 대한 SSL/TLS 암호화 구성에 대해 설명합니다. 주요 문제는 자체 서명 인증서의 보안 영향을 사용하는 것입니다. [문자 수 : 159]

기사는 MySQL에서 파티셔닝, 샤딩, 인덱싱 및 쿼리 최적화를 포함하여 대규모 데이터 세트를 처리하기위한 전략에 대해 설명합니다.

기사는 MySQL Workbench 및 Phpmyadmin과 같은 인기있는 MySQL GUI 도구에 대해 논의하여 초보자 및 고급 사용자를위한 기능과 적합성을 비교합니다. [159 자].

이 기사에서는 Drop Table 문을 사용하여 MySQL에서 테이블을 떨어 뜨리는 것에 대해 설명하여 예방 조치와 위험을 강조합니다. 백업 없이는 행동이 돌이킬 수 없으며 복구 방법 및 잠재적 생산 환경 위험을 상세하게합니다.

기사는 외국 열쇠를 사용하여 데이터베이스의 관계를 나타내고 모범 사례, 데이터 무결성 및 피할 수있는 일반적인 함정에 중점을 둡니다.

이 기사에서는 PostgreSQL, MySQL 및 MongoDB와 같은 다양한 데이터베이스에서 JSON 열에서 인덱스를 작성하여 쿼리 성능을 향상시킵니다. 특정 JSON 경로를 인덱싱하는 구문 및 이점을 설명하고 지원되는 데이터베이스 시스템을 나열합니다.

기사는 준비된 명령문, 입력 검증 및 강력한 암호 정책을 사용하여 SQL 주입 및 무차별 적 공격에 대한 MySQL 보안에 대해 논의합니다 (159 자)


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

뜨거운 주제



