SQL: Insert Into

This entry is part 10 of 20 in the series SQL Tutorial

The are generally 2 ways to use insert into statement.

insert into tableName (column1, column2, column3..) values (value1, value2, value3..)
insert into tableName values (value1, value2, value3...)

In our earlier examples, we have already used method 1 and so let’s look at method 2.

create table artiste
 id int auto_increment primary key, 
 artiste varchar(30)

insert into artiste
(0,'Rod Stewart'),
(0,'New Order');

Note that for the id column, it is an auto increment primary key value and we can put 0 to let the sql auto increment itself.

The 0 can also be replaced by using NULL.

Series Navigation<< SQL: More Select Examples
SQL: Insert current time or timestamp >>