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

Instructor InputsSession 3..Session OverviewThis session includes the following topics: Create potx

18 228 0
Tài liệu đã được kiểm tra trùng lặp

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

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 1,05 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Slide 3 Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Knowledge Byte Contd.. Slide 5 Installing Win

Trang 1

Instructor Inputs S e

Trang 3

This session includes the following topics:

„ Best practices

„ Tips and Tricks

Slide 1

Installing Windows XP Professional Using Attended Installation

Slide 1 of 21 Ver 1.0

Querying, Managing, and Administering Databases Using SQL Server 2005

Collaborate Session 3

Objectives

In this session, you will learn about:

Creating an XML document Storing XML data in XML columns Using XQuery

Best Practices while using the DML commands and creating indexes in SQL Server 2005

Tips and Tricks that will help you effectively use DML commands and use indexes in SQL Server 2005 FAQs related to DML commands and indexes in SQL Server 2005

Trang 4

Slide 2 of 21 Ver 1.0 Collaborate Session 3

Knowledge Byte

XML is a markup language that is used to describe the structure of data in a standard hierarchical manner.

An XML document is composed of a number of components that can be used to represent information in a hierarchical order These components are:

Processing Instruction Tags

Elements Content Attributes Comments

Document Type Definition (DTD) or XML Schemas can be used to define the structure of an XML document.

Slide 3

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Knowledge Byte (Contd.)

You can save the following types of data in the columns with the XML data types:

Untyped XML data

To store the untyped XML data, you can use columns or variables with the XML data type

Typed XML data

To store the typed XML data, you need to first register the schema associated with the data in the XML schema collection objects in the database.

XQuery is a language that uses a set of statements and functions provided by the XML data type to extract data

Trang 5

Slide 4 of 21 Ver 1.0 Collaborate Session 3

Knowledge Byte (Contd.)

The XQuery language includes the following statements:

for

Used to iterate through a set of nodes at the same level as in an XML document.

let

Used to declare variables and assign values.

order by

Used to specify a sequence

where

Used to specify criteria for the data to be extracted.

return

Used to specify the XML returned from a statement.

Slide 5

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Knowledge Byte (Contd.)

XQuery statements use the following functions provided by the XML data type:

Query

Used to extract XML from an XML data type

Value

Used to return a single value from an XML document.

Exist

Used to check the existence of a node in an XML data

Trang 6

Slide 6 of 21 Ver 1.0 Collaborate Session 3

Best Practices

The fastest schema changes occur when you:

Add a column with the NULL property

Add a column with the NULL and DEFAULT properties

Change the NOT NULL property to NULL

Add the DEFAULT constraint

Drop the CHECK or DEFAULT constraint.

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]

Slide 7

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Best Practices (Contd.)

Improve performance by creating a clustered index

A clustered index physically orders the data in a table based

on a single or composite column

Trang 7

Slide 8 of 21 Ver 1.0 Collaborate Session 3

Tips and Tricks

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'

To check whether the indexes created on your database are useful or not you can use

sys.dm_db_index_usage_stats.

Slide 9

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Tips and Tricks (Contd.)

To insert values from another table along with some literals, you can use the following syntax:

INSERT INTO <table name> [(<col list>)] SELECT

<collist>|<literal value> FROM <table name>

To determine if a particular object is a table or a view, you can use the OBJECTPROPERTY metadata function.

Trang 8

Slide 10 of 21 Ver 1.0 Collaborate Session 3

How maximum columns are allowed with each INSERT statement?

The maximum columns allowed with each INSERT statement

is 1024 columns.

FAQs

Slide 11

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

How many nonclustered indexes can be created on a table?

You can create 249 non-clustered indexes on a table.

FAQs (Contd.)

Trang 9

Slide 12 of 21 Ver 1.0 Collaborate Session 3

By default on which key the clustered index is created?

The clustered key is created on the Primary key by default.

FAQs (Contd.)

Slide 13

Installing Windows XP Professional Using Attended Installation 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.

FAQs (Contd.)

Trang 10

Slide 14 of 21 Ver 1.0 Collaborate Session 3

Does SQL Server 2000 have a support for partition tables?

No, SQL Server 2000 does not support partition tables.

FAQs (Contd.)

Slide 15

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

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.

FAQs (Contd.)

Trang 11

Slide 16 of 21 Ver 1.0 Collaborate Session 3

Why it is suggested to have 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.

FAQs (Contd.)

Slide 17

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Challenge

Which of the following is not true about Untyped data?

It is a well-formed data

It is not associated with any schema SQL Server does not validate Untyped data SQL Server does not store the data in well-formed structure.

Trang 12

Slide 18 of 21 Ver 1.0 Collaborate Session 3

Challenge (Contd.)

Which of the following is not a statement used with the XQuery language?

order by let sort by where

Answer:

sort by

Slide 19

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Challenge (Contd.)

Which of the following is not a function used by the XQuery language?

Query For Value Exist

Answer:

For

Trang 13

Slide 20 of 21 Ver 1.0 Collaborate Session 3

Challenge (Contd.)

Which of the following is not a component of an XML document?

Elements Attributes Quotes Comment

Answer:

Quotes

Slide 21

Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005

Challenge (Contd.)

Which of the following is the correct syntax for using a comment entry in an XML document?

<! Comment Entry >

< Comment Entry >

<!Comment Entry!>

<! Comment Entry !>

Trang 14

1 d It is not stored as well-formed structure by the SQL Server

2 c sort by

3 b For

4 c Quotes

5 a <! Comment Entry >

Trang 15

1 Which of the following is a not an example of an INSERT statement on Student table

with ID and Name columns?

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’

3 Which of the following command is not a DML command?

4 Which of the following is a correct TRUNCATE statement?

5 What does flag value 3 indicate in an openxml function?

a The flag value indicates retrieving the element values

Trang 16

Column Name Data Type Constraint

Date_Evnt datetime

Events Table

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?

=’Accts’

c UPDATE EmpDetails SET Department=’Accounts’ FOR Department =’Accts’

Department =’Accts’

8 Which of the following is an invalid command to delete records from a table?

Trang 17

b PATH

Solutions

2 SELECT * INTO ProdEmp from Emp where dept=’Production’

5 The flag value indicates retrieving both the element and attribute values

6 INSERT Events(EventID, EventName, Location) VALUES (‘104’, 'annual day',

‘angel gardens’)

10 AUTO

Trang 18

Querying is a basic operation performed on a table The data of a table is stored on

multiple data pages on the disk When a user queries a data value from the table, the query processor searches for the data value in all the data pages When it finds the data value, it returns the result set With an increasing volume of data, this process of querying data takes time Creating an index on a table solves the problem of slow query processing time Discuss the different types of indexing In addition, discuss the different situations in which each index type is helpful

Instructor Inputs

You can conduct the discussion as follows:

„ Encourage the students to discuss the different types of indexing

„ Move the discussion to the situations where each index type is useful

Solution

The SQL Server allows you to create the following types of indexes:

„ Clustered index

„ Nonclustered index

Clustered Index

A clustered index is an index that sorts and stores the data rows in the table based on their key values Therefore, the data is physically sorted in the table when a clustered index is defined on it Only one clustered index can be created per table Therefore, you should build the index on attributes that have a high percentage of unique values and are not modified often

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