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 |
|
1994.4.123
by Marisa Plumb
doc fixes |
12 |
INSERT statements that use VALUES syntax can insert multiple rows. To do this, use the multi row VALUES syntax (include multiple lists of column values, each enclosed within parentheses and separated by commas): |
2194.5.2
by Andrew Hutchings
Fix SQL markup |
13 |
|
14 |
.. code-block:: mysql |
|
1994.4.86
by Marisa Plumb
insert -- added multirow insert explanation and example |
15 |
|
16 |
INSERT INTO music (artist, album, date_prod, genre) VALUES |
|
17 |
('Beatles', 'Abbey Road', '1969-09-26', 'rock'), |
|
18 |
('The Velvet Underground', 'The Velvet Underground', '1969-03-05', 'rock'); |
|
19 |
||
2194.5.2
by Andrew Hutchings
Fix SQL markup |
20 |
or: |
21 |
||
22 |
.. code-block:: mysql |
|
1994.4.86
by Marisa Plumb
insert -- added multirow insert explanation and example |
23 |
|
24 |
INSERT INTO table_1 (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); |
|
25 |
||
2194.5.2
by Andrew Hutchings
Fix SQL markup |
26 |
The following statement is incorrect since the number of values in the list does not match the number of column names: |
27 |
||
28 |
.. code-block:: mysql |
|
1994.4.86
by Marisa Plumb
insert -- added multirow insert explanation and example |
29 |
|
30 |
INSERT INTO table_1 (a,b,c) VALUES(1,2,3,4,5,6,7,8,9); |
|
31 |
||
32 |
VALUE is a synonym for VALUES where performing a single or multirow INSERT. |
|
33 |
||
2194.5.3
by Andrew Hutchings
Markup fixes |
34 |
Performance
|
35 |
-----------
|
|
1994.4.86
by Marisa Plumb
insert -- added multirow insert explanation and example |
36 |
|
2194.5.2
by Andrew Hutchings
Fix SQL markup |
37 |
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. |