|=--------------------------------------------------=|
  _________________  .____     ___________________
 /   _____/\_____  \ |    |    \_   _____/\______ \
 \_____  \  /  / \  \|    |     |    __)_  |    |  \
 /        \/   \_/.  \    |___  |        \ |    `   \
/_______  /\_____\ \_/_______ \/_______  //_______  /
        \/        \__>       \/        \/         \/


|=--------------------------------------------------=|
. |03.03 - Rows inserting                            .
|=--------------------------------------------------=|

  In last chapter we created table. It has 3 columns:
user_key, user_name  and user_password. Let's  say we
would like to populate the table with some data.

  To add rows into the table we would use clause:
INSERT INTO ...

  We  have  3 users.  All  the  users have  the  same
password. So we would use 3 commands to do so:

  insert into users (user_name, user_password)
    values ('user1','pass');
 
  insert into users (user_name, user_password)
    values ('user2','pass');

  insert into users (user_name, user_password)
    values ('user3','pass');

  In some cases  we know what rows we  want to insert
and  we  don't want  to  waste  computer and  network
resources to run multiple commands. In that case it's
possible to insert  all the known rows  at once. This
can be achieved by:

  insert into users (user_name, user_password) values
    ('user1','pass'),
    ('user2','pass'),
    ('user3','pass')
  ;

  In  either case  table users  now contains  3 rows.
It  has  to  be  said  that the  table  users  had  3
columns. But we specified only 2 columns for the data
inserting.

  The  reason  is  we   have  user_key  specified  as
autoincrement and if it's not specified in the insert
clause it  does auto populate itself  when the column
is omitted while inserting data into the table.

  Inserting  data  is  a Data  Manipulation  Language
(DML).  Normally  if  the  database  is  not  in  the
autocommit mode we would have to issue COMMIT command
after each DML statement.  Previous chapter was given
to  data creating.  CREATE TABLE  is Data  Definition
Language. When using DDL  statements there is no need
to COMMIT  data. It changes the  structure of current
database and no COMMIT is needed.

  If we  would like  to add 4th  row and  provide the
INSERT statement without the columns specification we
would have to explicitly name  all the 3 columns like
this:

  insert into users values (4,'user4','pass');

  In next chapter we will try to query prepared data.


|=--------------------------------------------------=|
; v  | Thanks Linux and Vim | buy me a coffee   | o |;
|=--------------------------------------------------=|