insert statement-insert line

You can insert a line using the insert statement.

#insert statement
insert into table name (column name 1, column name 2, ...) values ​​(field value 1, field value 2, ...);

This is a sample insert statement.

insert into book (id, name, price) values ​​(1,'Perl', 2000);

Behavior of insert statement when auto_increment is specified

When creating a table, "auto_increment" is specified in the field definition. The field is automatically incremented by an integer and set to its value.

#There is a field for which "auto_increment" is specified in the field definition.
create table book (
  id int primary key auto_increment,
  name varchar (150) not null default'',
  pirce int not null default 0
) engine = InnoDB charset = utf8mb4;

Suppose the current auto_increment is 3. In that case, suppose you execute the following insert statement.

insert into book (name, price) values ​​('Perl', 2000);

Then the following data will be inserted.

id, name, price
4,'Perl', 2000

If you want to insert data from CSV data

If you want to insert data from CSV data, use the special syntax of the insert statement.

It is possible to insert data with other delimiter data, such as tab-separated data instead of comma-separated data.

Associated Information