1.update 语句

update  table set  [column,column......] where  column =''

示例: update   customers

set   cust_credit_limit = 20000

where   cust_id = 2789;

2.delete 语句

delete from table where  条件

示例; delete from customers

where cust_state_province = 'QT';

备注;truncate customers 也可以删除该表的所有记录,但是它在出错不允许回滚的

3.数据排序

order by

示例: select cust_id,cust_state_province, cust_credit_limit

from customers

where cust_credit_limit = 15000

and cust_state_province  in ('QT','CT')

order by cust_state_province ,cust_id ;

备注:oracle 默认的是按照升序排序,如果需要降序就 要在排序字段后面添加desc

示例:select cust_id ,cust_state_province,cust_credit_limit

from  customers

where cust_credit_limit =15000

and cust_state_province in  ('UT','CT')

order by cust_state_province ,cust_id desc

4.group by

group by 主要是分组 来进行求和 或者其它运算

示例:select prod_subcategory,avg(amout_sold)

from sales s ,products p

where s.prod_id = p.prod_id

and prod_category = 'Electronics'

group by prod_subcategory ;

5.having

在对group by 操作的使用having 字句可以限制返回的组

示例:select prod_subcategory,avg(amout_sold)

from sales s ,products p

where s.prod_id = p.prod_id

and prod_category = 'Electronics'

group by prod_subcategory

having avg(amout_sold) > 300;

6.子查询

sql 一个强大功能就是创建子查询,即查询中嵌套查询。这一功能使得基于另一结果或者其他结果集进行查询成为可能

示例:

select prod_id ,prod_name ,prod_category

from products

where  prod_list_price  =

(

select  max(prod_list_price) from products

);

7:集合操作

union 返回两表中无任何重复的所有行

示例:select * from x

union

select *from y

union all 返回两表中所以行(包含重复)

示例:select * from x

union all

select *from y

intersect 返回两表中都存在的行

示例:select * from x

intersect

select *from y

最新文章

  1. ionic + cordova+angularJs 搭建的H5 App完整版总结
  2. Html5 学习系列(五)Canvas绘图API快速入门(2)
  3. win 10 远程连接出现 "由于安全设置错误, 客户端无法连接到远程计算机. 确定你已登录到网络后.” 错误
  4. POJ1087 A Plug for UNIX(网络流)
  5. DelegatingFilterProxy
  6. Django 1.8 - “No migrations to apply” when run migrate after makemigrations 解决办法
  7. Healwire Online Pharmacy 3.0 Cross Site Request Forgery / Cross Site Scripting
  8. Python测试Post请求
  9. Java之Servlet
  10. ionic 搜索双向数据绑定失效
  11. Jscraft 使用 Shell 与预先加载别名混合使用
  12. Matrix67|自由职业者,数学爱好者
  13. [ 转]Shell中参数($0,$1,$#,$NF,$@等)的含义
  14. IDC门外汉-单线、双线、智能多线、BGP的区别
  15. java 等额本金与等额本息
  16. 根据日期查询年龄js
  17. 【洛谷2416】泡芙(Tarjan+LCA)
  18. hdu 1394 逆序数(线段树)
  19. PERL学习之模式匹配
  20. JavaScript-Tool:Ext JS

热门文章

  1. 安装elasticsearch-head插件
  2. 如何提高Axure设计的效率 提高Axure设计效率的10条建议
  3. java代码优化写法(转摘)
  4. Ubuntu中使用Nginx+rtmp搭建流媒体直播服务
  5. vue生成条形码/二维码/带logo二维码
  6. hdfs写并发问题
  7. xsd解析xml
  8. CodeForces - 1087D
  9. LUGOU P3374 【模板】树状数组 1(CDQ 分治)
  10. PHP7中标量类型declare的用法详解