Slide 11.7: The CREATE TABLE statement
Slide 11.9: The SELECT statement
Home

The INSERT INTO Statement


The INSERT INTO statement is used to insert new rows into a table.

The syntax of inserting data into a table is given on the right:
 INSERT INTO  table_name
   VALUES (value1, value2,....)

 SQL> insert into  Persons
   2    values ('Hansen', 'Ola', 'Timoteivn 10', 'Sandnes');

 1 row created.

 SQL> insert into  Persons
   2    values ('Svendson', 'Tove', 'Borgvn 23', 'Sandnes');

 1 row created.

 SQL> insert into  Persons
   2    values ('Pettersen', 'Kari', 'Storgt 20', 'Stavanger');

 1 row created.

You can also specify the columns for which you want to insert data:
 INSERT INTO
   table_name (column1, column2, ...)
   VALUES (value1, value2, ....)

 SQL> insert into  Persons  (LastName, Address)
   2    values ('Rasmussen', 'Storgt 67');

 1 row created.

The columns not specified are inserted with values NULL.

LastName FirstName Address  City 
Hansen Ola Timoteivn 10 Sandnes
Svendson Tove Borgvn 23 Sandnes
Pettersen Kari Storgt 20 Stavanger
Rasmussen   Storgt 67