Home > Database > Mysql Tutorial > body text

How to write insert sql statement

青灯夜游
Release: 2020-09-14 17:15:14
Original
45096 people have browsed it

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,...);
Copy after login

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,...);
Copy after login

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,"女");
Copy after login

or

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

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!

Related labels:
sql
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template