insert 插入数据
注意:字符串类型必须加 引号
1.添加1条记录: #注意:添加的记录与表头要对应
insert into 表名 (字段1,字段2,字段3...) values(值1,值2,值3...);
2.添加多条记录:
insert into 表名 (字段1,字段2,字段3) values
(值1,值2,值3),
(值4,值5,值6),
(...)...;
3.用 set 添加记录:
insert into 表名 set 字段1=值1,字段2=值2......;
#
insert into users (username, email, birthdate, is_active)
values ('test', 'test@runoob.com', '1990-01-01', true);
#插入多行数据,可以在 VALUES 子句中指定多组数值
insert into users (username, email, birthdate, is_active)
values
('test1', 'test1@runoob.com', '1985-07-10', true),
('test2', 'test2@runoob.com', '1988-11-25', false),
('test3', 'test3@runoob.com', '1993-05-03', true);
#
insert into test set id=11044,sex="男";
# NULL:用于自增长列的占位符,表示系统将为 id 列生成一个唯一的值
insert into users
values (NULL,'test', 'test@runoob.com', '1990-01-01', true);
dalete 删除数据
1.删除表中数据:
1.删除某个记录,等于删除那个整条记录
delete from 表名 where 对应字段=值;
delete from test where id=11011;
2.删除表中所有记录,但不删除表本身
delete from 表名;
delete from test;
update 更新数据
1.更新记录:更新指定字段所在行的其他其字段
update 表名 set 字段1=value1, 字段2=value2, ...
where 给谁修改;
#
update test set max=1114, tel=234567
where id=11044;