SQL statement parsing order and execution order

Source: Internet
Author: User

SQL statement Execution Order
1.from clauses assemble data from different data sources
The 2.where clause filters the record rows based on the specified criteria
The 3.group by clause divides data into multiple groupings
4. Using aggregation functions for calculations
5. Filtering groupings using the HAVING clause
6. Calculate All expressions
Field of 7.select
8. Use order by to sort the result set

SQL Statement Parsing order
1. Table name and condition field are incorrectly written
SELECT * from Sysuser where username= ' abc '
Result: ORA-00942: Table or view does not exist

2. Condition fields and query columns are incorrectly written
Select UserID from Sys_user where Username= ' abc '
Result: ORA-00904: "USERNAME": Invalid identifier

3. Query fields and GROUP BY statements are incorrectly written
Select UserID from Sys_user where User_name= ' abc ' GROUP BY username
Result: ORA-00904: "USERNAME": Invalid identifier

4. The query field and the order by field are incorrectly written
Select UserID from Sys_user where user_name= ' abc ' ORDER BY username
Result: ORA-00904: "USERNAME": Invalid identifier

5.group by and order by fields are incorrectly written
Select user_id from Sys_user where User_name= ' abc ' GROUP BY username order by UserID
Result: ORA-00904: "USERID": Invalid identifier

6.join and where field is incorrectly written
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 '
Result: ORA-00904: "A". " USERID ": Invalid identifier

SQL statement parsing order and execution order

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.