当使用insert into select 批量加载数据的时候,可能会碰到因为某些数据不符合加载条件,而导致整个insert 语句无法执行,全部ro
当使用insert into select 批量加载数据的时候,可能会碰到因为某些数据不符合加载条件,而导致整个insert 语句无法执行,全部rollback。这时可以使用DML 错误日志的特性,解决这个问题。
只需要创建一个日志表,并且在使用dml语句的时候添加dml error logging 语句,即可将错误的rows记录到日志表中,而且不会影响已经加载到表中的数据。最后修正这些无法加载的数据。
操作步骤如下:
1. 创建一个日志表
可以使用DBMS_ERRLOG包创建,或者手动的创建日志表。如果使用dbms_errlog.create_error_log来创建日志表,默认的会将源表的所有列都加入需要记录的行列中。
2. 执行insert ,并且添加error logging 语句。
3. 最后查询日志表,修改无法加载的数据。
以下是一个insert into select 批量加载的例子:
第一步创建日志表
创建测试表target_t
create table target_t (id number(4),namevarchar2(2000)) ;
创建源表source_t
create table source_t as select level as id ,'name' || level as name from dual connect by level
使用存储过程创建error logging table target_err_t
使用DBMS_ERRLOG.CREATE_ERROR_LOG会自动补全表中的所有列到日志表中。(这里表名竟然不区分大小写,,看来OracleDabase在向好的方向发展了)
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG(dml_table_name => 'target_t',err_log_table_name=> 'target_err_log') ;
查看一下表结构
dexter@ORCL> desc target_err_log ;
Name Null? Type
------------------------------------------------------------- ------------------------------------
ORA_ERR_NUMBER$ NUMBER
ORA_ERR_MESG$ VARCHAR2(2000)
ORA_ERR_ROWID$ ROWID
ORA_ERR_OPTYP$ VARCHAR2(2)
ORA_ERR_TAG$ VARCHAR2(2000)
ID VARCHAR2(4000)
NAME VARCHAR2(4000)

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
