找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
数据库中的字段怎么测试?
1:数据类型(int bigint char varchar float date)
2:约束类型
3:存储的值的一个边界值

操作表结构命令?
create databases,drop,create table,alter table

数据库增删改查的命令?
select * from  查询所有字段数据
insert into  增加
delete from  删除
update 表 set  更新
truncate 表  删除表数据,不会删除结构=delete from 表
drop table 表  删除表(包括结构和数据)
delete from test where id=1  指定删除哪条数据
(可以id〉3)删除ID大于3的
drop database 数据库  删除数据库
update 表 set 修改数据 where id=1 修改id=1这一行的数据
update 表 set 修改数据 where 条件(条件为有相同的就会更改所有行)
select name from 表 where id=1  查询id=1中name的数据
(多个字段用逗号隔开)(!=不等于)
select * from 表 where 条件 and  条件 (同时满足两个条件)
select * from 表 where 条件 or 条件 (或者(满足一个))
                           between xx and xx 指定范围
                           in(xx,xx)在指定范围
                           not in(xx,xx)不再范围
                           is null 查询空的数据
                           is not null 不是空
                           字段 like “%xx”模糊匹配
                           字段 limit 2,3 从第3行开始查看后面3行

select * from student1 order by age desc  将查询数据age进行排序大到小
select * from student1 order by age asc   将查询数据age进行排序小到大
select sum(求和)(math) from student1 对math字段进行求和
select sum(math) from student1 group by class 对每个班math进行求和
select sum(math),class from student1 group by class 显示每个班对应math求和的数量
select sum(math),class from student1 group by class having sum(math)>100
(对班级进行分组,求和math值,选择大于100的值和班级)
select sum(math)as(取别名) t,class from student1 group by class having t>100
(对sum(math)取别名为t)
having 通常用在 group by 后面(一起使用)
group by 前面可以使用where 进行刷选条件 后面不能再接where














分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册