DBA > Job Interview Questions > DERBY Java Database FAQs

SQL Tips - Tricks of the VALUES Clause - Multipl

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

SQL Tips - Tricks of the VALUES Clause - Multiple Rows

Derby supports the complete SQL-92 VALUES clause; this is very handy in several cases. The first useful case is that it can be used to insert multiple rows:

INSERT INTO OneColumnTable VALUES 1,2,3,4,5,6,7,8
INSERT INTO TwoColumnTable VALUES
(1, 'first row'),
(2, 'second row'),
(3, 'third row')

Dynamic parameters reduce the number of times execute requests are sent across:


-- send 5 rows at a time:
PREPARE p1 AS 'INSERT INTO ThreeColumnTable VALUES
(?,?,?), (?,?,?), (?,?,?), (?,?,?), (?,?,?)
EXECUTE p1 USING 'VALUES (''1st'',1,1,''2nd'',2,2''3rd'',
3,3,''4th'',4,4,''5th'',5,5)'

(Continued on next question...)

Other Job Interview Questions