第二章:数据库与表的基本操作-DML插入、修改、删除数据

直接学习:https://edu.csdn.net/course/play/27328/362520
DML插入、修改、删除数据:
#1、插入:
create table contacts (
id int not null auto_increment primary key,
name varchar(50),
sex tinyint default 1,
phone varchar(20)
);
desc contacts;
insert into contacts (name,sex,phone) values (“张三”,1,“15888888888”);
select * from contacts;
insert into contacts (name,sex,phone) values (“tom’s cat”,1,‘13888888888’),(“lucy’s cat”,1,‘18888888888’);
select * from contacts;
insert into contacts (name,phone) values (‘李四’,15188888888);

select * from contacts;
#2、修改
update contacts set sex =2;
update contacts set sex =1;

update contacts set sex=2 where id=3;
#3、删除
delete from contacts where id=3;
select * from contacts;
delete from contacts
select * from contacts;

发布了107 篇原创文章 · 获赞 6 · 访问量 968

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/105421561