Showing posts with label order of execution of sql query in oracle. Show all posts
Showing posts with label order of execution of sql query in oracle. Show all posts

Thursday, November 9, 2017

Sequence of Execution of The SQL Queries


What actually sets SQL Server apart from other programming languages is the way SQL Server processes its code. Generally, most programming language process statement from top to bottom. By contrast, SQL Server processes them in a unique order which is known as Logical Query Processing Phase. These phases and their orders are given as follows:

1. FROM
2. ON
3. OUTER/LEFT/RIGHT/INNER/CROSS Joins
4. WHERE
5. GROUP BY
6. CUBE 
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP


So always think to optimise the data and result top to bottom with this sequence for getting quick results.

SQL Script to list out name of tables and its records in the database

SET NOCOUNT ON  DBCC UPDATEUSAGE(0)  -- DB size. EXEC sp_spaceused -- Table row counts and sizes. CREATE TABLE #temptable  (      [name] NVA...