Home  >  Article  >  Database  >  How to write insert sql statement

How to write insert sql statement

青灯夜游
青灯夜游Original
2019-03-04 17:23:5145093browse

How to insert sql statement: [insert into table_name values ​​(value1, value2, value3,...);]. You can also specify the column name when inserting data, such as [insert into table_name (column1)].

How to write insert sql statement

##Basic syntax of SQL insert into

(Recommended tutorial:

mysql video tutorial)

The insert into statement can be written in two forms:

1. There is no need to specify the column name to insert data, just provide the inserted value:

insert into table_name
values (value1,value2,value3,...);

2. You need to specify the column name and the value to be inserted:

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

Let’s take an example to see how to use the insert into statement to perform the insertion operation:

Existing data table demo :

How to write insert sql statement

After performing the following operations:

//必须顺序插入demo对应的字段
insert into demo values(5,"小小",20,"女");

or

//值和名字对应即可
insert into demo(name, id,age,sex) values("赵峰",6,21,"男");

Output:


How to write insert sql statement

The above is the detailed content of How to write insert sql statement. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn