Bulk Delete:
DELETE from MyTable WHERE ID in (;
BULK INSERT:
INSERT into MyTable (id,name) VALUES (1, ' 123 ');
INSERT into MyTable (id,name) VALUES (2, ' 456 ');
INSERT into MyTable (id,name) VALUES (3, ' 789 ');
The second method uses union ALL to insert the operation:
INSERT into MyTable (id,name)
SELECT 4, ' 000 '
UNION All
SELECT 5, ' 001 '
UNION All
SELECT 6, ' 002 ';
It's said to be faster than the first!
The third method of
INSERT into MyTable (id,name) VALUES (7, ' 003 '), (8, ' 004 '), (9, ' 005 ');
Example:
Table: Leafjob (
Leafnum INT not NULL PRIMARY KEY,
Machine VARCHAR (15));
Delete: Delete from leafjob where Leafnum in (1,2,4);
Insert:
INSERT into Leafjob (leafnum, machine) VALUES (1, ' r1leaf3 '), (2, ' r1leaf22 ');
Insert into Leafjob (leafnum, machine) Select 4, ' The ' union ALL select 1, ' R1LEAF3 ' union ALL Select 2, ' R1leaf22 ';
Insert into Leafjob (leafnum, machine) Select 1, ' R1LEAF3 ' union select 2, ' R1leaf22 ';
Note: Performance issues require specific testing. Example tested under MySQL, version:4.1.20
SQL Bulk Delete and BULK insert