1. Trang chủ
  2. » Công Nghệ Thông Tin

CollaborateChapter 3..Knowledge ByteIn this section, you will learn about: Creating an XML pot

10 214 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 284,65 KB

Nội dung

Collaborate Chapter 3 Querying, Managing, and Administering Databases Using SQL Server 2005 3.3 ¤NIIT In this section, you will learn about:  Creating an XML document  Storing XML data in XML columns  Using XQuery Read the following topic in the Appendix of the book Querying and Managing Data Using SQL Server 2005:  Extensible Markup Language (XML) Read the following topic in the Manipulating the XML Data section of Chapter 5 of the book Querying and Managing Data Using SQL Server 2005:  Storing XML Data in XML columns Read the following topic in the section Manipulating the XML Data of Chapter 5 of the book Querying and Managing Data Using SQL Server 2005:  Using XQuery Knowledge Byte Creating an Extensible Markup Language (XML) Document Storing XML Data in XML Columns Using XQuery ¤NIIT 3.4 Querying, Managing, and Administering Databases Using SQL Server 2005 This section contains:  Best practices  Tips and tricks  FAQs The following best practices can be considered while using the DML commands and creating indexes in SQL Server 2005:  Use faster schema changes: SQL Server 2005 supports schema changes. However some schema changes are faster than others. The fastest schema changes occur when you: z Add a column with the NULL property. z Add a column with the NULL and DEFAULT properties. z Change the NOT NULL property to NULL. z Add the DEFAULT constraint. z Drop the CHECK or DEFAULT constraint.  Find tables without clustered index: To find out tables without a clustered index in a database use the following set of commands: use <database name> select distinct [Table] = object_name(object_id) from sys.indexes where index_id=0 and objectproperty(object_id,'IsUserTable')=1 order by [Table]  Improve performance by creating a clustered index: A clustered index physically orders the data in a table based on a single or composite column. The records stored in a table without a clustered index are not in a specific physical order. Whenever you need to query the column or columns used for the clustered index, SQL Server helps you sequentially read the data in a clustered index an extent (8 data pages, or 64K) at a time. This makes it easy for the disk subsystem to read the data quickly from disk, especially if there is a lot of data to be retrieved. From the Expert’s Desk Best Practices Querying, Managing, and Administering Databases Using SQL Server 2005 3.5 ¤NIIT The following tips and tricks will help you effectively use DML commands and use indexes in SQL Server 2005:  To change the date and time on the Windows server where SQL Server is installed, use the following script in Query Editor: USE master EXEC xp_cmdshell 'echo 06/16/2005 | date' EXEC xp_cmdshell 'echo 15:01:40 | time' The first EXEC command changes the date in the SQL Server. The second EXEC command changes the time in the SQL Server.  To check whether the indexes created on your database are useful or not you can use sys.dm_db_index_usage_stats. When an index is created on a table by using the CREATE INDEX statement, the index is not reflected in the index DMV’s. When an index is used by a Select, Insert, Update, or Delete statement, the index is reflected in the index DMV and its use is captured by sys.dm_db_index_usage_stats. It returns counts of different types of index operations and the time each type of operation was last performed. The greater the count of different types of index operations for an index, the greater is the usefulness of the index.  To insert values from another table along with some literals, you can use the following syntax: INSERT INTO <table name> [(<col list>)] SELECT <col list>|<literal value> FROM <table name>  To determine if a particular object is a table or a view, you can use the OBJECTPROPERTY metadata function. The following example checks if the object is a view or not: IF OBJECTPROPERTY( OBJECT_ID( '[dbo].[Customers]' ), 'IsView' ) = 1 PRINT 'Object is a view'  How many maximum columns are allowed with each INSERT statement? The maximum columns allowed with each INSERT statement is 1024 columns.  How many nonclustered indexes can be created on a table? You can create 249 non-clustered indexes on a table.  By default on which key the clustered index is created? The clustered key is created on the Primary key by default. Tips and Tricks FAQs ¤NIIT 3.6 Querying, Managing, and Administering Databases Using SQL Server 2005  What is the maximum limit of creating partitions? The maximum limit of creating partitions is 1000.  Does SQL Server 2000 have a support for partition tables? No, SQL Server 2000 does not support partition tables.  How is the indexed view updated when any row is inserted, updated or deleted from a table? The SQL Server maintains the indexed views same as normal indexes. When the data is updated in a table the indexed view is automatically updated.  Why it is recommended to create the first index of a table as CLUSTERED and UNIQUE? The first index of the table must be UNIQUE to allow easy lookup of records in the view by the key value. It must be CLUSTERED because only a clustered index can enforce uniqueness and store the rows at the same time. Querying, Managing, and Administering Databases Using SQL Server 2005 3.7 ¤NIIT 1. Which of the following is not true about Untyped data? a. It is a well-formed data b. It is not associated with any schema c. It is not validated by the SQL Server. d. It is not stored as well-formed structure by the SQL Server. 2. Which of the following is not a statement used with the XQuery language? a. order by b. let c. sort by d. where 3. Which of the following is not a function used by the XQuery language? a. Query b. For c. Value d. Exist 4. Which of the following is not a component of an XML document? a. Elements b. Attributes c. Quotes d. Comment 5. Which of the following is the correct syntax for using a comment entry in an XML document? a. <! Comment Entry > b. < Comment Entry > c. <!Comment Entry!> d. <! Comment Entry !> Challenge ¤NIIT 3.8 Querying, Managing, and Administering Databases Using SQL Server 2005 1. Which of the following is a not an example of an INSERT statement on Student table with ID and Name columns? a. INSERT Student VALUES (1, ‘Sam’) b. INSERT Student(ID,Name) VALUES(1,’Sam’) c. INSERT Student(Name)VALUES(‘Sam’) d. INSERT Student VALUES(‘Sam’) 2. Consider a table named Emp with columns named empid, empname and dept. Which of the following command will create a new table named ProdEmp from Emp table? The new table should contain records of employees from the Production department. a. SELECT * INTO ProdEmp from Emp where dept=’Production’ b. SELECT from Emp * INTO ProdEmp where dept=’Production’ c. SELECT * INTO Emp from ProdEmp where dept=’Production’ d. SELECT * INTO ProdEmp from Emp 3. Which of the following command is not a DML command? a. INSERT b. UPDATE c. ALTER TABLE d. DELETE 4. Which of the following is a correct TRUNCATE statement? a. TRUNCATE TABLE Emp b. TRUNCATE EMP c. TRUNCATE Emp WHERE Rt_Dt<’12/01/2000’ d. TRUNCATE TABLE Emp WHERE Rt_Dt<’12/01/2000’ 5. What does flag value 3 indicate in an openxml function? a. The flag value indicates retrieving the element values b. The flag value indicates retrieving both the element and attribute values c. The flag value indicates retrieving the default value d. The flag value indicates retrieving the attribute value Home Assignment Querying, Managing, and Administering Databases Using SQL Server 2005 3.9 ¤NIIT 6. Consider the following table for the column names, data types and constraints for the columns of table Events. Column Name Data Type Constraint EventID char Primary key EventName char NOT NULL Location char NOT NULL Date_Evnt datetime Which command will you use to insert a record without the date of event? a. INSERT Events VALUES (‘104’, 'annual day', ‘angel gardens’, ‘12\15\2006’) b. INSERT Events(EventID, EventName, Location) VALUES (‘104’, 'annual day', ‘angel gardens’) c. INSERT Events VALUES (‘104’, 'annual day', ‘angel gardens’) d. INSERT (EventID, EventName, Location) Events VALUES (‘104’, 'annual day', ‘angel gardens’, ‘12\15\2006’) 7. Which statement will change the value in Department field to Accounts where the value of Department filed is Accts in EmpDetail table? a. UPDATE EmpDetails SET Department=’Accounts’ WHERE Department =’Accts’ b. UPDATE EmpDetails SET Department=’Accounts’ c. UPDATE EmpDetails SET Department=’Accounts’ FOR Department =’Accts’ d. UPDATE TABLE EmpDetails SET Department=’Accounts’ WHERE Department =’Accts’ 8. Which of the following is an invalid command to delete records from a table? a. DELETE FROM Db1.Tbl1 b. DELETE Tbl1 WHERE Fld1=’val1’ c. TRUNCATE TABLE Tbl1 d. TRUNCATE TABLE Tbl1 WHERE Fld1=’val1’ 9. Which command will create a pointer to the internal representation of the XML document? a. EXEC sp_xml_preparedocument @Doc, @XMLDoc b. EXEC sp_xml_preparedocument @Doc OUTPUT, @XMLDoc c. EXEC sp_prepareddocument @Doc OUTPUT, @XMLDoc d. sp_xml_preparedocument @Doc OUTPUT ¤NIIT 3.10 Querying, Managing, and Administering Databases Using SQL Server 2005 10. Which mode of the FOR XML clause is used to return query results as nested XML elements? a. RAW b. PATH c. AUTO d. EXPLICIT . Chapter 3 Querying, Managing, and Administering Databases Using SQL Server 2005 3. 3 ¤NIIT In this section, you will learn about:  Creating an XML document  Storing XML data in XML columns. Byte Creating an Extensible Markup Language (XML) Document Storing XML Data in XML Columns Using XQuery ¤NIIT 3. 4 Querying, Managing, and Administering Databases Using SQL Server 2005 This. Managing, and Administering Databases Using SQL Server 2005 3. 5 ¤NIIT The following tips and tricks will help you effectively use DML commands and use indexes in SQL Server 2005:  To change

Ngày đăng: 31/07/2014, 15:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN