APPENDIX B

image

XQuery Data Types

SQL Server 2014 supports the data types defined in the XQuery Data Model (XDM). The supported data types are listed with their definitions in Table B-1. The diagram in Figure B-1 is a quick reference showing the relationships between the XDM data types.

9781484201466_Fig21-01.jpg

Figure B-1. XQuery data type system

Table B-1. XQuery Data Types

Type

Description

Base Types

xs:anySimpleType

Base type for all simple built-in types.

xs:anyType

Base type for xs:anySimpleType and complex built-in types.

Date/Time Types

xs:date

Represents a Gregorian calendar–based date value exactly one day in length, in the format yyyy-mm-dd[time_offset]. time_offset can be a capital Z for zero-meridian (UTC) or in the format +/-hh:mm to represent a UTC offset. An example of a valid xs:date is 2006-12-25Z, which represents December 25, 2006, UTC time.

xs:dateTime

Represents a Gregorian calendar–based date and time value with precision to 1/1000th of a second. The format is yyyy-mm-ddThh: mm:ss.sss[time_offset]. Time is specified using a 24-hour clock. As with xs:date, time_offset can be a capital Z (UTC) or a UTC offset in the format +/-hh:mm. A valid xs:dateTime value is 2006-10-30T13:00: 59.500-05:00, which represents October 30, 2006, 1:00:59.5 PM, US Eastern Standard time. Unlike in SQL Server 2005, in SQL Server 2012 the xs:dateTime type maintains the time zone information you assign instead of automatically converting all date/time values to a single time zone. The time zone also isn’t mandatory in SQL Server 2012.

xs:duration

Represents a Gregorian calendar–based temporal (time- based) duration, using the format PyyyyYmmMddDThhHmmMss.sssS. P0010Y03M12DT00H00M00.000S, for instance, represents 10 years, 3 months, 12 days.

xs:gDay

Represents a Gregorian calendar–based day. The format is dd[time_offset] (notice the three preceding hyphen [-] characters). The time_offset is optional. A valid xs:gDay value is 09Z, which stands for the ninth day of the month, UTC time.

xs:gMonth

Represents a Gregorian calendar–based month. The format is --mm[time_offset] (notice the two preceding hyphen characters). time_offset is optional. A valid xs:gMonth value is -12, which stands for December.

xs:gMonthDay

Represents a Gregorian calendar–based month and day. The format is --mm-dd[time_offset] (notice the two preceding hyphens). The time_offset is optional. A valid xs:gMonthDay value is --02-29 for February 29.

xs:gYear

Represents a Gregorian calendar–based year. The format is yyyy[time_offset]. The time_offset is optional. The year can also have a preceding hyphen character indicating a negative (BCE—“before the Christian Era”) year as opposed to a positive (CE—“Christian Era”) date. A valid xs:gYear value is -0044 for 44 BCE. Notice that all four digits are required in the year representation, even for years that can be normally represented with fewer than four digits.

xs:gYearMonth

Represents a Gregorian calendar–based year and month. The format is yyyy-mm[time_offset]. The time_offset is optional and can be Z or a UTC offset. A valid xs:gYearMonth value is 2001-01 for January 2001.

xs:time

Represents a time value with precision to 1/1000th of a second, using a 24-hour clock representation. The format is hh:mm:ss.sss [time_offset]. As with other temporal data types, time_offset can be Z (UTC) or a UTC offset in the format +/-hh:mm. A valid xs:time value is 23:59:59.000-06:00, which represents 11:59:59 PM, US Central Standard time. The canonical representation of midnight in 24-hour format is 00:00:00.

Binary Types

xs:base64Binary

Represents Base64-encoded binary data. Base64-encoding symbols are defined in RFC 2045 (www.ietf.org/rfc/rfc2045.txt) as A through Z, a through z, 0 through 9, +, /, and the trailing = sign. Whitespace characters are also allowed, and lowercase letters are considered distinct from uppercase letters. An example of a valid xs:base64Binary value is QVByZXNzIEJvb2tzIEFuZCBTUUwgU2V ydmVyIDIwMDU=.

xs:hexBinary

Represents hexadecimal-encoded binary data. The symbols defined for encoding data in hexadecimal format are 0 through 9, A through F, and a through f. Upper- and lowercase letters A through F are considered equivalent by this data type. An example of a valid xs:hexBinary value is 6170726573732E636F6D.

Boolean Type

xs:Boolean

Represents a Boolean binary truth value. The values supported are true (1) and false (0). An example of a valid xs:boolean value is true.

Numeric Types

xs:byte

Represents an 8-bit signed integer in the range -128 to +127.

xs:decimal

Represents an exact decimal value up to 38 digits in length. These numbers can have up to 28 digits before the decimal point and up to 10 digits after the decimal point. A valid xs:decimal value is 8372.9381.

xs:double

Represents a double-precision floating-point value patterned after the IEEE standard for floating-point types. The representation of values is similar to xs:float values nE[+/-]e, where n is the mantissa followed by the letter E or e and an exponent e. The range of valid values for xs:double is approximately -1.79E+308 to -2.23E-308 for negative numbers, 0, and +2.23E-308 to +1.79E+308 for positive numbers.

xs:float

Represents an approximate single-precision floating point value per the IEEE 754-1985 standard. The format for values of this type is nEe, where n is a decimal mantissa followed by the letter E or e and an exponent. The value represents n·10e. The range for xs:float values is approximately -3.4028e+38 to -1.401298E-45 for negative numbers, 0, and +1.401298E-45 to +3.4028e+38 for positive numbers. The special values -INF and +INF represent negative and positive infinity. SQL Server doesn’t support the XQuery-specified special value NaN, which stands for “not a number.” A valid xs:float value is 1.98E+2.

xs:int

Represents a 32-bit signed integer in the range -2147483648 to +2147483647.

xs:integer

Represents an integer value up to 28 digits in length. A valid xs:integer value is 76372.

xs:long

Represents a 64-bit signed integer in the range -9223372036854775808 to +9223372036854775807.

xs:negativeInteger

Represents a negative nonzero integer value derived from the xs:integer type. It can be up to 28 digits in length.

xs:nonNegativeInteger

Represents a positive or zero integer value derived from the xs:integer type. It can be up to 28 digits in length.

xs:nonPositiveInteger

Represents a negative or zero integer value derived from the xs:integer type. It can be up to 28 digits in length.

xs:positiveInteger

Represents a positive nonzero integer value derived from the xs:integer type. It can be up to 28 digits in length.

xs:short

Represents a 16-bit signed integer in the range -37268 to +32767.

xs:unsignedByte

Represents an unsigned 8-bit integer in the range 0 to 255.

xs:unsignedInt

Represents an unsigned 32-bit integer in the range 0 to +4294967295.

xs:unsignedLong

Represents an unsigned 64-bit integer in the range 0 to +18446744073709551615.

xs:unsignedShort

Represents an unsigned 16-bit integer in the range 0 to +65535.

String Types

xs:ENTITIES

A space-separated list of ENTITY types.

xs:ENTITY

Equivalent to the ENTITY type from the XML 1.0 standard. The lexical space has the same construction as an xs:NCName.

xs:ID

Equivalent to the ID attribute type from the XML 1.0 standard. An xs:ID value has the same lexical construction as an xs:NCName.

xs:IDREF

Represents the IDREF attribute type from the XML 1.0 standard. The lexical space has the same construction as an xs:NCName.

xs:IDREFS

A space-separated list of IDREF attribute types.

xs:language

A language identifier string representing natural language identifiers as specified by RFC 3066 (www.ietf.org/rfc/rfc3066.txt). A complete list of language codes is maintained by the IANA registry at www.iana.org/assignments/language-subtag-registry. Language identifiers must conform to the regular expression pattern [a-zA- Z]{1,8}(-[a-zA-Z0-9]{1,8})*. An example of a valid language identifier is tlh, which is the identifier for the Klingon language.

xs:Name

An XML name string. A name string must match the XML-specified production for Name. Per the standard, a Name must begin with a letter, an underscore, or a colon, and may then contain a combination of letters, numbers, underscores, colons, periods, hyphens, and various other characters designated in the XML standard as combining characters and extenders. Refer to the XML standard at www.w3.org/TR/2000/WD-xml-2e-20000814#NT-Name  for specific information about these additional allowable Name characters.

xs:NCName

A noncolonized name. The format for an xs:NCName is the same as for xs:Name, but without colon characters.

xs:NMTOKEN

An NMTOKEN type from the XML 1.0 standard. An xs:NMTOKEN value is composed of any combination of letters, numbers, underscores, colons, periods, hyphens, and XML combining characters and extenders.

xs:NMTOKENS

A space-separated list of xs:NMTOKEN values.

xs:normalizedString

An XML whitespace-normalized string, which is one that doesn’t contain the whitespace characters #x9 (tab), #xA (line feed), and #xD (carriage return).

xs:string

An XML character string.

xs:token

An XML whitespace-normalized string with the following additional restrictions on #x20 (space) characters: it can have no leading or trailing spaces, and it can’t contain any sequences of two space characters in a row.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset