~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/insert.rst

  • Committer: Andrew Hutchings
  • Date: 2011-02-23 13:08:09 UTC
  • mto: (2196.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2197.
  • Revision ID: andrew@linuxjedi.co.uk-20110223130809-mbd2rypxod2tfre6
Fix SQL markup

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
   multi row inserts, performance thereof.
14
14
 
15
 
INSERT statements that use VALUES syntax can insert multiple rows. To do this, use the multirow VALUES syntax (include multiple lists of column values, each enclosed within parentheses and separated by commas): ::
 
15
INSERT statements that use VALUES syntax can insert multiple rows. To do this, use the multirow VALUES syntax (include multiple lists of column values, each enclosed within parentheses and separated by commas):
 
16
 
 
17
.. code-block:: mysql
16
18
 
17
19
        INSERT INTO music (artist, album, date_prod, genre) VALUES
18
20
        ('Beatles', 'Abbey Road', '1969-09-26', 'rock'),
19
21
        ('The Velvet Underground', 'The Velvet Underground', '1969-03-05', 'rock');
20
22
 
21
 
or ::
 
23
or:
 
24
 
 
25
.. code-block:: mysql
22
26
        
23
27
        INSERT INTO table_1 (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
24
28
 
25
 
The following statement is incorrect since the number of values in the list does not match the number of column names: ::
 
29
The following statement is incorrect since the number of values in the list does not match the number of column names:
 
30
 
 
31
.. code-block:: mysql
26
32
 
27
33
        INSERT INTO table_1 (a,b,c) VALUES(1,2,3,4,5,6,7,8,9);
28
34
 
30
36
 
31
37
**Performance**:
32
38
 
33
 
A multi-row INSERT involving three rows will require roughly one third of the time required to execute the three single-row statements. This performance improvement can become quite significant over a large number of statements. 
 
 
b'\\ No newline at end of file'
 
39
A multi-row INSERT involving three rows will require roughly one third of the time required to execute the three single-row statements. This performance improvement can become quite significant over a large number of statements.