12

Click here to load reader

Order by and join

Embed Size (px)

DESCRIPTION

JOIN ORDER BY

Citation preview

Page 1: Order by and join

Microsoft Sql Server

SELECT Statement

Page 2: Order by and join

Natural Order

• When you do a SELECT FROM the table, the rows will ALWAYS appear in the same order of insertion

• It’s the “natural” chronologically-entered order of the rows

Page 3: Order by and join

Data Page

• Table data is stored as a collection of 8-KB (8192-byte) pages.

• 8060 bytes for the data on each page.

• A row of data can not span multiple pages.

Page 4: Order by and join

Pages and Extents

• The fundamental unit of data storage in SQL Server is the page.

• Size of a page is 8 KB (96-byte header )• Header store system information about the page: • Page Number• Page Type• Free pace on the page• Allocation unit ID

Page 5: Order by and join

Data Page

Page 6: Order by and join

Extents

• Page type: Data, Index, LOB, ROW_OVERFLOW_DATA etc.

• Extents are the basic unit in which space is managed.

• Extents are a collection of eight physically contiguous pages

Page 7: Order by and join

JOINING OF TABLES

• INNER JOIN • LEFT OUTER JOIN • RIGHT OUTER JOIN • FULL OUTER JOIN

Page 8: Order by and join

INNER JOIN

Page 9: Order by and join

LEFT OUTER JOIN

Page 10: Order by and join

RIGHT OUTER JOIN

Page 11: Order by and join

FULL OUTER JOIN

Page 12: Order by and join

THANK YOU