XQuery Language Reference.pdf
(
2196 KB
)
Pobierz
XQuery Language Reference
SQL Server 2012 Books Online
Summary
: XQuery is a language that can query structured or semi-structured XML data.
With the xml data type support provided in the Database Engine, documents can be
stored in a database and then queried by using XQuery. XQuery is based on the existing
XPath query language, with support added for better iteration, better sorting results,
and the ability to construct the necessary XML.
Category:
Reference
Applies to
: SQL Server 2012
Source
: SQL Server Books Online
(
link to source content
)
E-book publication date
: June 2012
Copyright © 2012 by Microsoft Corporation
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.
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 fictitious. 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 authors, 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.
Contents
XQuery Language Reference (SQL Server) ............................................................................................................6
XQuery Basics ...................................................................................................................................................................8
Sequence and QNames ............................................................................................................................................9
Expression Context and Query Evaluation...................................................................................................... 12
Atomization ................................................................................................................................................................ 16
Effective Boolean Value ......................................................................................................................................... 18
Type System ............................................................................................................................................................... 19
Sequence Type Matching.................................................................................................................................. 23
Error Handling ........................................................................................................................................................... 32
Comments in XQuery.............................................................................................................................................. 34
XQuery and Static Typing ..................................................................................................................................... 35
XQuery Expressions ..................................................................................................................................................... 38
Primary Expressions................................................................................................................................................. 39
Path Expressions ....................................................................................................................................................... 43
Specifying Axis in a Path Expression Step................................................................................................... 45
Specifying Node Test in a Path Expression Step ...................................................................................... 50
Specifying Predicates in a Path Expression Step ...................................................................................... 59
Using Abbreviated Syntax in a Path Expression ....................................................................................... 64
Sequence Expressions ............................................................................................................................................ 66
Arithmetic Expressions ........................................................................................................................................... 71
Comparison Expressions........................................................................................................................................ 72
Logical Expressions.................................................................................................................................................. 78
XML Construction..................................................................................................................................................... 79
FLWOR Statement and Iteration......................................................................................................................... 94
Ordered and Unordered Expressions .............................................................................................................107
Conditional Expressions.......................................................................................................................................107
Quantified Expressions.........................................................................................................................................111
SequenceType Expressions.................................................................................................................................113
Validate Expressions..............................................................................................................................................123
Modules and Prologs................................................................................................................................................123
XQuery Prolog .........................................................................................................................................................124
Type Casting Rules in XQuery ...............................................................................................................................126
XQuery Functions against the xml Data Type .................................................................................................131
Functions on Numeric Values............................................................................................................................133
ceiling Function...................................................................................................................................................133
floor Function.......................................................................................................................................................135
round Function....................................................................................................................................................136
XQuery Functions on String Values.................................................................................................................137
concat Function...................................................................................................................................................137
contains Function ...............................................................................................................................................140
substring Function .............................................................................................................................................142
string-length Function......................................................................................................................................144
lower-case Function .........................................................................................................................................148
upper-case Function ........................................................................................................................................150
Functions on Boolean Values.............................................................................................................................152
not Function .........................................................................................................................................................152
Functions on Nodes ..............................................................................................................................................154
number Function ................................................................................................................................................155
local-name Function..........................................................................................................................................157
namespace-uri Function ..................................................................................................................................158
Context Functions ..................................................................................................................................................160
last Function .........................................................................................................................................................161
position Function................................................................................................................................................162
Functions on Sequences......................................................................................................................................164
empty Function ...................................................................................................................................................164
distinct-values Function...................................................................................................................................167
id Function ............................................................................................................................................................168
Aggregate Functions.............................................................................................................................................173
count Function ....................................................................................................................................................173
min Function ........................................................................................................................................................176
max Function........................................................................................................................................................177
avg Function.........................................................................................................................................................178
sum Function........................................................................................................................................................179
Data Accessor Functions......................................................................................................................................182
string Function.....................................................................................................................................................182
data Function .......................................................................................................................................................185
Constructor Functions ..........................................................................................................................................188
Boolean Constructor Functions.........................................................................................................................192
true Function........................................................................................................................................................192
false Function.......................................................................................................................................................194
Functions Related to QNames ..........................................................................................................................194
expanded-QName .............................................................................................................................................195
local-name-from-QName ...............................................................................................................................199
namespace-uri-from-QName........................................................................................................................201
SQL Server XQuery Extension Functions .......................................................................................................201
sql:column() Function .......................................................................................................................................202
sql:variable() Function.......................................................................................................................................205
XQuery Operators Against the xml Data Type................................................................................................207
Additional Sample XQueries Against the xml Data Type............................................................................209
General XQuery Use Cases .................................................................................................................................209
XQueries Involving Hierarchy ............................................................................................................................219
XQueries Involving Order....................................................................................................................................221
XQueries Handling Relational Data.................................................................................................................228
Plik z chomika:
kisuke
Inne pliki z tego folderu:
10_essential_tools_for_mobile_working_article.pdf
(380 KB)
2934_WSG_Win8_ShortcutKeys_QuickReferenceGuide_External.docx
(235 KB)
3a_Microsoft_Classroom_Deployment.pdf
(2017 KB)
4114_Configuration_as_code_Automating_Windows_Server_2016.docx
(44 KB)
4133_Power-BI-mobile-apps—enabling-data-analytics-on-the-go_Article.docx
(673 KB)
Inne foldery tego chomika:
Fantastyka, opowieści, dzieła itp
Git Essential Training
Inne
Masterton Graham
RPG
Zgłoś jeśli
naruszono regulamin