Python学习第二十二课——Mysql 表记录的一些基本操作 (增删改)
记录基本操作:
增:(insert into)
基本语法:
insert into 表名(字段) values(对应字段的值);
例子1:
insert into employee(id,name,age,salary) values(1,"憨憨",24,5000); 指定添加insert into employee values(2,"憨憨",0,24,"技术部",5000); 对应添加
insert into employee set name="玫玫";
添加多条:
insert into employee(name,age,salary) values("憨憨",24,500), ("憨",24,5000), ("玫玫",24,50), ("阿妹",24,5); 添加多条
删(delect from)
基本语法: delect from 表名 where 字段=“根据什么字段删除”
DELETE from employee where id=2; 删除一条 DELETE from employee where id=2 or id=3; 删除多条
改 (update set)
基本语法:update 表明 set 字段=“修改值” where 字段=“根据那个字段修改”
例子:
update employee set salary=20000 where id=1;
update employee set department="销售部" where name="玫玫";