Microsoft Press SQL Server 2012 T-SQL Fundamentals (2012).pdf

(7957 KB) Pobierz
902095718.005.png
Microsoft ® SQL Server ®
2012 T-SQL Fundamentals
Itzik Ben-Gan
902095718.006.png 902095718.007.png 902095718.008.png 902095718.001.png
Published with the authorization of Microsoft Corporation by:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, California 95472
Copyright © 2012 by Itzik Ben-Gan
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any
means without the written permission of the publisher.
ISBN: 978-0-735-65814-1
1 2 3 4 5 6 7 8 9 M 7 6 5 4 3 2
Printed and bound in the United States of America.
Microsoft Press books are available through booksellers and distributors worldwide. If you need support related
to this book, email Microsoft Press Book Support at mspinput@microsoft.com . Please tell us what you think of
this book at http://www.microsoft.com/learning/booksurvey .
Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/
Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of
their respective owners.
The example companies, organizations, products, domain names, email addresses, logos, people, places, and
events depicted herein are ictitious. No association with any real company, organization, product, domain name,
email address, logo, person, place, or event is intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this book is provided without
any express, statutory, or implied warranties. Neither the author, O’Reilly Media, Inc., Microsoft Corporation, nor
its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or
indirectly by this book.
Acquisitions and Developmental Editor: Russell Jones
Production Editor: Kristen Borg
Editorial Production and Illustration: Online Training Solutions, Inc.
Technical Reviewer: Gianluca Hotz and Herbert Albert
Copyeditor: Kathy Krause
Indexer: Allegro Technical Indexing
Cover Design: Twist Creative • Seattle
Cover Composition: Karen Montgomery
Contents at a Glance
Foreword
xix
Introduction
xxi
Background to T-SQL Querying and programming
1
ChapTer 1
Single-Table Queries
27
ChapTer 2
Joins
99
ChapTer 3
Subqueries
129
ChapTer 4
Table expressions
157
ChapTer 5
Set Operators
191
ChapTer 6
Beyond the Fundamentals of Querying
211
ChapTer 7
ChapTer 8 Data Modiication
247
Transactions and Concurrency
297
ChapTer 9
programmable Objects
339
ChapTer 10
Getting Started
375
appendIx a
Index
397
About the Author
413
902095718.002.png
Contents
Foreword .......................................................xix
Introduction ....................................................xxi
Chapter 1
Background to T-SQL Querying and Programming 1
Theoretical Background ............................................1
SQL ........................................................2
Set Theory ..................................................3
Predicate Logic ..............................................4
The Relational Model ........................................4
The Data Life Cycle ...........................................9
SQL Server Architecture ...........................................12
The ABC Flavors of SQL Server ...............................12
SQL Server Instances ........................................14
Databases .................................................15
Schemas and Objects .......................................18
Creating Tables and Deining Data Integrity .........................19
Creating Tables .............................................19
Deining Data Integrity ......................................21
Conclusion ......................................................25
Chapter 2
Single-Table Queries 27
Elements of the SELECT Statement .................................27
The FROM Clause ...........................................29
The WHERE Clause ..........................................31
The GROUP BY Clause .......................................32
What do you think of this book? We want to hear from you!
Microsoft is interested in hearing your feedback so we can continually improve our
books and learning resources for you. To participate in a brief online survey, please visit:
microsoft.com/learning/booksurvey
vii
902095718.003.png 902095718.004.png
Zgłoś jeśli naruszono regulamin