美文网首页我爱编程
003,数据库的增,删,改操作

003,数据库的增,删,改操作

作者: rain129 | 来源:发表于2018-04-16 20:05 被阅读36次

数据库的操作主要是【增,删,改,查】,但是今天先学习一下比较简单的【增,删,改】,后面再单独学习【查】;

增 - insert

insert into 表名(字段名1,字段名2) values(值1,值2);
insert into 表名(字段名1,字段名2) values(值1,值2),(值1,值2) //一次插入多条数据

删 - delete 【一定带上where条件】

delete from 表名 where 字段名=条件值;

改 - update 【一定要带上where条件】

update 表名 set 字段名1=‘新值’, 字段名2=‘新值’ where id=3;
示例:
update user set username="张三", password="123456" where id=3;

另外记录下where条件的几种写法

1. where id=2
2. where id>=3 and id<=5
3. where id between 3 and 54. where id in(6,8,9)5. where id=6 or id=8 or id=9`

相关文章

网友评论

    本文标题:003,数据库的增,删,改操作

    本文链接:https://www.haomeiwen.com/subject/cbpekftx.html