数据库(sql)常用命令(2)

DML语句(数据库操作语言)

1.insert(添加语句/插入语句):

语法:insert into 表名 values (字段1,字段2,字段3,.........)

示例1:insert into  student (id,name,......) values(10,'詹华',.......);

示例2:插入多条:insert into  student (id,name,......) values(10,'詹华',.......),(20,'张三',.......)

2.update(更新数据语句/修改)

语法:update 表名 set 字段名 [where 条件]

示例:update student set name='詹六'  where id=10;

3.delete(删除数据语句)

语法:delete  from 表名 [where 条件语句/]

示例:delete from student where id=10;

4.truncate(清空表数据)

语法:truncate 表名

示例:truncate student

注意:truncate 用于完全清空表数据 , 但表结构 , 索引 , 约束等不变。

DQL语句(数据库查询语言)(关键字 select) 1.1

::select语句执行顺序
from 查询表 ----》join 表连接 -------> on 过滤条件 ------》where 过滤条件 ------》group by
进行分组 -----》 having 过滤条件 -------》 order by 进行排序 ------》 select 选择列显示

1.查寻整个表的数据:

示例: select * from student [这个*指代全部数据]

2.查询表中某个字段:where 关键字(指定的)

示例:select *from student where sno=10;

2.1:where查询条件。

2.1.1:and  或  &&  (表示并且的意思,需要满足这左右两边的条件)

语法:select *  from 表名 where  字段条件

示例1:select *from  score where degree=>60 &&degree<=80;

示例2:select *from  score where degree=>60 and degree<=80;

2.1.2: bewten....and....(与2.1.1效果相同)

示例:select*from score where degree  bewten  60  and  80;

2.1.3: or 或 ||   (表示或者的意思)

示例1:select*from score where degree>60  or  class='95033';

示例2:select *from  score where degree>60 || class='95033';

2.1.4: not 或 !  (!取反)

示例1:select *from score where not degree=80

示例2:select *from score where degree !=80

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值