sql中数据处理:

一.添加新数据!
插入单行记录
1.create table box(
name varchar(30) not null,
id int not null primary key,
student varchar(20),
gender char(2) default 0 comment '0男:1女'
);
insert into box(name, id, student) values('xiaohong',123,'123'),('bingxin',565,'334');
select*from box;
插入新数据:insert into 表名(列名)values (列表参数)也可加,(列表参数);
插入多行数据:insert into <表名> select <select语句>
insert into games select year+12,city from games;
insert inti Students (studenyname,studenyid) select studenyname+2,studenyid from Students.
二.更新新数据。
1.update 表名 set 要改的值 where <过滤的条件>
create table box3(
name varchar(30) not null,
id int not null primary key,
student varchar(20),
gender char(2) default 0 comment '0男:1女'
);
insert into box3(name, id, student) values('minxing',365,'668'), ('lunxun',778,'388');

update set box3 name='xiaotao',id='596' where student='668';
delete from box3 where id='365' and student='388';
select*from box3;
2.删除数据
delete from 表名 where <过滤条件>
delete from box3 where id='596';
delete from box3 where id='335'and/or name='xiaotao';

 

 

一。查询的基本结构:
select 列
from 表名
where (过滤的)
group by 以....来分组
having 判定...条件
order by(排序)asc升序,desc降序
二:
查找:select 列名 from表名
select name,student,subject from box;
取别名:select name'姓名' ,subject'奖项' from box;
返回限定行数查询:
select top 5 student from box(查询第一条到第五条)
三模糊查询:
select *from box where limit 0,4(o是从0行开始,4是指长度)
select*from box where like '%liu%';
select age from student order by age desc limit 0,8;

转载于:https://www.cnblogs.com/ba1314/p/4058289.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值