zoukankan      html  css  js  c++  java
  • sql语句解析顺序和执行顺序

    sql语句执行顺序
    1.from子句组装来自不同数据源的数据
    2.where子句基于指定的条件对记录行进行筛选
    3.group by子句将数据划分为多个分组
    4.使用聚集函数进行计算
    5.使用having子句筛选分组
    6.计算所有的表达式
    7.select 的字段
    8.使用order by对结果集进行排序

    sql语句解析顺序
    1.表名和条件字段写错
    select * from sysuser where username='abc'
    结果:ORA-00942: 表或视图不存在

    2.条件字段和查询列写错
    select userid from sys_user where username='abc'
    结果:ORA-00904: "USERNAME": 标识符无效

    3.查询字段和group by语句写错
    select userid from sys_user where user_name='abc' group by username
    结果:ORA-00904: "USERNAME": 标识符无效

    4.查询字段和order by字段写错
    select userid from sys_user where user_name='abc' order by username
    结果:ORA-00904: "USERNAME": 标识符无效

    5.group by和order by 字段写错
    select user_id from sys_user where user_name='abc' group by username order by userid
    结果:ORA-00904: "USERID": 标识符无效

    6.join和where字段写错
    select a.* from
    (select * from sys_user) a
    left join
    (select * from sys_user) b
    on (a.userid=b.user_id)
    where a.username='abc'
    结果:ORA-00904: "A"."USERID": 标识符无效

  • 相关阅读:
    leetcode——91.解码方法
    leetcode——64.最小路径和
    Layui上传图片2.0版
    LINQ中判断日期时间段
    Http基础
    Js中数组,字符串的常用方法
    C#数组,ArrayList,List区别
    08-01 通过线性回归了解算法流程
    08-00 课程习得
    C-02 推荐系统
  • 原文地址:https://www.cnblogs.com/gavinYang/p/8168949.html
Copyright © 2011-2022 走看看