navicat的基本使用技巧

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33210743/article/details/79209399

一、Navicat常用快捷键

1,Ctrl+q就会弹出一个sql输入窗口
2,Ctrl+r就执行sql了
3,按f6会弹出一个命令窗口
4,Ctrl+/ 注释
5,Ctrl +Shift+/ 解除注释
6,Ctrl+R 运行选中的SQL语句
7,Ctrl+Shift+R 只运行选中的sql语句
8,Ctrl+L 删除选中行内容
9,Ctrl+D 表的数据显示显示页面切换到表的结构设计页面,但是在查询页面写sql时是复制当前行并粘贴到下一行
10,Ctrl+N 打开一个新的查询窗口
11,Ctrl+W 关闭当前查询窗口
12,鼠标三击选择当前行

二、增删库表、字段、索引等操作

select s_name from t_stu;
insert into t_stu(sname,sage)value(‘王欢’,23)—增加
delete from t_stu where sage = 22;–删除
update t_stu set sage=25 where sname =’唐强’;-修改

三、常用的关键字:

like%/like_、BETWEEN AND、in、is null、desc、DISTINCT、group by、limit

四、聚合函数:

SUM()、AVG()、COUNT、MAX()、MINI()

五、SQL执行顺序 F-W-G-S-H-O

第一步: 执行FROM
第二步: WHERE条件过滤T
第三步: GROUP BY 分组
第四步: 执行SELECT投影列
第五步:HAVING条件过滤
第六步: 执行ORDER BY 排序

注意!! :在分组查询中,能够查询的字段只能是分组字段和聚合函数
WHERE运行在分组前,故后面不能有聚合函数,HAVING运行在分组后,只能作聚合函数的过滤

六、CASE WHEN THEN

CASE
WHEN total_amount<10 then 0
when total_amount>=10 and total_amount<50 then 1
when total_amount>=50 and total_amount<100 then 2
when total_amount>=100 and total_amount<200 then 3
when total_amount>=200 and total_amount<500 then 4
when total_amount>=500 and total_amount<1000 then 5
else 6
end

猜你喜欢

转载自blog.csdn.net/qq_33210743/article/details/79209399