-
Quick way to insert unique records into a table with Primary Key
I have a large table containing 500,000 records or more with a primary key.
When attempting to INSERT records into the table, I need to ensure that I
don't violate the Primary Key constraint. To do this I use a subquery in
the WHERE clause, but I find that the INSERT statement with large record
sets sometimes takes several hours to complete because the subquery is generated
for every record being inserted into the table. Is there a quick way to
insert unique records into a table that has a primary key? An example of
the SQL statement I am currently using is shown below.
INSERT INTO TARGET (PHONENUM, NAME)
SELECT CUSTPHONE, CUSTNAME FROM SOURCE WHERE CUSTPHONE NOT IN (SELECT PHONENUM
FROM TARGET)
Thanks,
Suresh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|