XML IN THE DATABASE: THE XML DATA TYPE

XML IN THE DATABASE: THE XML DATA TYPE to a CLOB (VARCHAR(MAX)), but you must convert it to and from a varchar type, rather than assign it. Like distinct types, the XML data type cannot be compared with other data types without being cast or converted, but unlike distinct types, two instances of an XML data type cannot be compared at all. Like a SQL:1999 distinct type, the XML type has its own methods; these methods enable the use of an alternate query language, XQuery. The data in an XMLtype does not follow the relational data model, but is based on the XML Infoset model, which is used to model structured that is, hierarchical data. A column that is defined as being of type XMLstores its data in the database itself. The column is not a pointer to an XML document on the file system. This means that XML data is included in the backup and restore process, is subject to ordinary SQL Server security (and some extensions to security, as we ll mention later), and participates in transactions, constraints, and logging. Having XML data inside a relational database may offend some relational purists, but it means that your data lives in a single repository for reasons of administration, reliability, and control. Using the XML Data Type in Tables Let s begin by using the XML data type to define a column in a table. The following DDL statement creates a table. CREATE TABLE xml_tab ( the_id INTEGER, xml_col XML) Note that you can also have a table that consists of only a single XML data type column; however, the XMLdata type cannot be used itself as a primary key. The following code, which attempts to use the XML column as a primary key, fails. CREATE TABLE xml_tab ( xml_col XML PRIMARY KEY) Interestingly, the following error message occurs when you try to make an XMLdata type the primary key: Column xml_col in table xml_tab is of a type that is invalid for use as a key column in an index. Later we will see that you can create an XML-specific index on this column, but this index will not be used in SQL comparisons it will be

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.