> For the complete documentation index, see [llms.txt](https://zpliu.gitbook.io/booknote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zpliu.gitbook.io/booknote/mysql/cha-ru/01.md).

# 插入数据

## 1.语法

* 插入数据类型要一致，列数要和值的数目一致
* 字符、日期类型数据需要使用单引号引起来
* 为空的字段，在插入时填入`NULL`或者

```sql
insert    into 表名(列名) values(值1....);

insert    into 表名(列名) values(值1,NULL,...)
```

另外一种

* 不支持多行插入

```sql
insert    into 表名 SET 列名=值,列名=值
```

## 2.多行插入

* 支持子查询

```sql
insert into 表名(列名) values (值1....),(值2....)
# 子查询方式
insert into 表名(列名) select 值1,值2;
```
