我想知道是否有任何方法继续插入重复键错误后选择.含义:我想忽略该异常并继续插入下一条记录.我熟悉ignore_row_on_dupkey_index,但据我所知,不应该在生产环境中使用提示.
几件事情:1.查询将数百万条记录插入空表中.我更喜欢一个好的解决方案,对性能影响很小.
谢谢,亚历克斯
使用ignore_row_on_dupkey_index的代码示例:
CREATE TABLE customers
( customer_id number(10) NOT NULL,
customer_name varchar2(50) NOT NULL,
city varchar2(50),
CONSTRAINT customers_pk PRIMARY KEY (customer_id)
);
CREATE TABLE customers_2
( customer_id number(10) NOT NULL,
customer_name varchar2(50) NOT NULL,
city varchar2(50)
);
insert into customers_2 values(1,'A','TLV');
insert into customers_2 values(2,'B','TLV');
insert into customers_2 values(2,'C','TLV');
insert into customers_2 values(3,'C','TLV');
SELECT * FROM customers_2
insert /*+ ignore_row_on_dupkey_index(customers, customers_pk) */
into customers select * from customers_2
select * from Customers;
Run Code Online (Sandbox Code Playgroud)