phpstudy

本文介绍了SQL的基本操作,包括创建表格、插入数据、删除数据、更新记录和查询信息。通过实例展示了如何使用`CREATE TABLE`定义表结构,`INSERT INTO`插入数据,`DELETE FROM`及`WHERE`子句进行有条件删除,`UPDATE`更新字段值,以及`SELECT`查询数据的各种方式。这些基本操作是数据库管理的基础。
摘要由CSDN通过智能技术生成
创建表
   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 = "小黄黄";

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值