~drizzle-trunk/drizzle/development

1878.5.4 by Brian Aker
Update documentation.
1
Inserting Data
1900.2.2 by Stewart Smith
fix docs warning: Title underline is too short in insert.rst
2
==============
1878.5.4 by Brian Aker
Update documentation.
3
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
4
In Drizzle you can make use of INSERT in order to insert data into a table.
1878.5.4 by Brian Aker
Update documentation.
5
6
A type query:
7
2194.5.3 by Andrew Hutchings
Markup fixes
8
.. code-block:: mysql
1878.5.4 by Brian Aker
Update documentation.
9
2194.5.3 by Andrew Hutchings
Markup fixes
10
   INSERT INTO A VALUES ("1");
1878.5.4 by Brian Aker
Update documentation.
11
2165.2.3 by Andrew Hutchings
Add favicon to docs
12
.. todo::
13
14
   multi row inserts, performance thereof.
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
15
2194.5.2 by Andrew Hutchings
Fix SQL markup
16
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):
17
18
.. code-block:: mysql
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
19
20
	INSERT INTO music (artist, album, date_prod, genre) VALUES
21
    	('Beatles', 'Abbey Road', '1969-09-26', 'rock'),
22
   	('The Velvet Underground', 'The Velvet Underground', '1969-03-05', 'rock');
23
2194.5.2 by Andrew Hutchings
Fix SQL markup
24
or:
25
26
.. code-block:: mysql
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
27
	
28
	INSERT INTO table_1 (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
29
2194.5.2 by Andrew Hutchings
Fix SQL markup
30
The following statement is incorrect since the number of values in the list does not match the number of column names:
31
32
.. code-block:: mysql
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
33
34
	INSERT INTO table_1 (a,b,c) VALUES(1,2,3,4,5,6,7,8,9);
35
36
VALUE is a synonym for VALUES where performing a single or multirow INSERT.
37
2194.5.3 by Andrew Hutchings
Markup fixes
38
Performance
39
-----------
1994.4.86 by Marisa Plumb
insert -- added multirow insert explanation and example
40
2194.5.2 by Andrew Hutchings
Fix SQL markup
41
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.