原文链接:https://www.cnblogs.com/mingmingming/p/11295200.html
一、INSERT INTO语句的基本用法
INSERT INTO 语句用于往表中插入新记录。
student表:
INSERT INTO语句有2种语法格式:
1、不指定列名,直接插入记录。
语法格式如下:
1
|
INSERT INTO 表名 VALUES(值 1 ,值 2. ..); |
例:
1
|
INSERT INTO student VALUES( 20190206 , '大明' , 4 ); |
结果:
注意,值必须与列对应,列数要一致,否则将会报错。’
2、指定列名,按列名插入记录。
语法格式如下:
1
|
INSERT INTO 表名(列名 1 ,列名 2. ..) VALUES(值 1 ,值 2. ..); |
例:
1
|
INSERT INTO student(student_number,name) VALUES( 20190207 , '大红' ); |
结果: