创建表
create table 表名(字段1,字段2...)
create table student
(
stu_id int(10),
stu_name varchar(20),
stu_gender char(2),
stu_date date
)
增
insert into 表名
values (值1,值2...)
insert into student
values (1,"老王","M","2022-06-20");
insert into student
values (2,"中王","FM","2022-06-20");
insert into student
values (3,"中王","FM","2022-06-20");
删
delete from 表名;
delete from student;
如何实现根据条件删除
where子句
delete from student
where stu_name = "老王";
AND 和 OR
delete from student
where stu_name = "中王"
AND stu_id = 3;
delete from student
where stu_id = 1
or stu_id = 2
改
update 表名 set 字段1 = 值1...;
update student
set stu_name = '大黄';
update student
set stu_name = '小黄黄'
where stu_id = 1;
查
select 字段1,字段2... from 表名;
select stu_id,stu_date from student;
select * from student;
select * from student
where stu_name = "小黄黄";
phpstudy
最新推荐文章于 2024-11-07 10:34:02 发布
本文介绍了SQL的基本操作,包括创建表格、插入数据、删除数据、更新记录和查询信息。通过实例展示了如何使用`CREATE TABLE`定义表结构,`INSERT INTO`插入数据,`DELETE FROM`及`WHERE`子句进行有条件删除,`UPDATE`更新字段值,以及`SELECT`查询数据的各种方式。这些基本操作是数据库管理的基础。
摘要由CSDN通过智能技术生成