~ubuntu-branches/ubuntu/quantal/drizzle/quantal

« back to all changes in this revision

Viewing changes to docs/insert.rst

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2011-03-02 10:38:38 UTC
  • mfrom: (1.2.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110302103838-4ezi8b065c4bv329
Tags: 2011.03.11-0ubuntu1
* New upstream release.
* Sleep no longer an so.
* Re-add get-orig-source, but this time with working.
* New symbol added to libdrizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Inserting Data
2
2
==============
3
3
 
4
 
In Dizzle you can make use of INSERT in order to insert data into a table.
 
4
In Drizzle you can make use of INSERT in order to insert data into a table.
5
5
 
6
6
A type query:
7
7
 
8
 
INSERT INTO A VALUES ("1");
 
8
.. code-block:: mysql
9
9
 
 
10
   INSERT INTO A VALUES ("1");
10
11
 
11
12
.. todo::
12
13
 
13
14
   multi row inserts, performance thereof.
 
15
 
 
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
 
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
 
 
24
or:
 
25
 
 
26
.. code-block:: mysql
 
27
        
 
28
        INSERT INTO table_1 (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
 
29
 
 
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
 
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
 
 
38
Performance
 
39
-----------
 
40
 
 
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.