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

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

16 205 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 16
Dung lượng 1,01 MB

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

Nội dung

This session includes the following topics: „ Creating partitioned indexes „ System-defined stored procedures „ Best practices „ Tips and Tricks Slide 1 Installing Windows XP Professiona

Trang 1

Instructor Inputs S e

Trang 3

This session includes the following topics:

„ Creating partitioned indexes

„ System-defined stored procedures

„ Best practices

„ Tips and Tricks

Slide 1

Installing Windows XP Professional Using Attended Installation

Slide 1 of 16

Ver 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005

Collaborate Session 4

Objectives

In this session, you will learn about:

Creating partitioned indexes System-defined stored procedures Best Practices while using the views, batches, stored procedures, and functions in SQL Server 2005 Tips and Tricks that will help you use views, batches, stored procedures, and functions in SQL Server 2005

FAQs related to procedures and full text index in SQL Server 2005

Trang 4

Slide 2 of 16

Knowledge Byte

In SQL Server 2005, indexes can also be partitioned based

on the value ranges

Partitioned indexes help improve query performance

To create a partitioned index, you need to perform the following tasks:

Create a partition function.

Create a partition scheme.

Create a clustered index.

Slide 3

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

Knowledge Byte (Contd.)

SQL Server 2005 provides a set of system-defined stored procedures used for general maintenance of a particular database or the database server in whole

Microsoft Word Document

Trang 5

Slide 4 of 16

Best Practices

Keep the stored procedures as small as possible This is useful in a situation where two users are accessing the same stored procedure at the same time and the two query plans are stored in the cache

Ensure that all stored procedures return a value indicating their status This will help evaluate their success or failure status

While creating a view if the records are combined from multiple tables having different number of columns, you should use the UNION ALL operator

When performing any operation on a table, such as inserting columns in a table, keep refreshing the dependent views.

Slide 5

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

Tips and Tricks

Use SET_NOCOUNT_ON at the beginning of SQL batches, stored procedures, and triggers This will increase the performance by reducing network traffic

Use the following procedure to find keywords in stored procedures:

CREATE PROCEDURE <proc name> @<var name>

VARCHAR(100) AS

SELECT routine_name FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_definition LIKE '%' + @<var name> + '%‘

ORDER BY

Trang 6

Slide 6 of 16

Tips and Tricks (Contd.)

Use catalog views to access metadata of different objects in SQL Server 2005 It is a rich mechanism that does not require access to system tables.

Use a batch to execute a set of SQL statements Use procedures to use a set of SQL statements more than once

Procedures allow you to save a set of SQL statements whereas batches are temporary in nature.

Slide 7

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

Can you write SQL Server 2005 stored procedures without the knowledge of any T-SQL statements?

The belief that the SQL Server 2005 stored procedures can be written without the knowledge of T-SQL statements is partially true While it is technically possible to create a stored procedure without using T-SQL, it is not possible to access any data without using T-SQL statements.

FAQs

Trang 7

Slide 8 of 16

Can a view contain a CASE statement?

Yes, you can use a CASE statement in a view, but you have

to create the view by using Query Analyzer and not SQL Server Enterprise Manager There is a limitation in creating views in Enterprise Manager when the view contains a CASE statement.

FAQs (Contd.)

Slide 9

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

Can you use the FREETEXT predicate in a programming language with a SELECT statement?

Yes, the FREETEXT predicate can be used in a programming language with a SELECT statement in the same way as it is used in SQL Server.

FAQs (Contd.)

Trang 8

Slide 10 of 16

Is it must to create a unique index on a table before creating

a full-text index on it?

Yes, it is must to create a unique index on a table before creating a full-text index on it.

FAQs (Contd.)

Slide 11

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

Can you create more that one full-text index on a table?

Yes, you can create more than one full-text index on table on different columns When you use the different full-text predicates with the SELECT statement, the suitable full-text index is automatically selected.

FAQs (Contd.)

Trang 9

Slide 12 of 16

Challenge

Which system-defined stored procedure is used to rename a view?

sp_renamedb sp_configure sp_recompile sp_rename

Answer:

sp_rename

Slide 13

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 description for the sp_configure stored procedure?

Its is used to display information about SQL Server configuration

Its is used to set the configuration of SQL Server 2005 Its is used to enable the CLR integration feature in the database

Its is used to extract the CLR integration information of the database

Answer:

Its is used to enable the CLR integration feature in the database

Trang 10

Slide 14 of 16

Challenge (Contd.)

Which edition of SQL Server 2005 allows partitioning?

Express Edition Enterprise Edition Standard Edition Developer Edition

Answer:

Enterprise Edition

Slide 15

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

Challenge (Contd.)

While creating a partitioned index, what do you create after creating a partition scheme?

Partition function Partition table Clustered index Nonclustered index

Answer:

Clustered index

Trang 11

Slide 16 of 16

Challenge (Contd.)

Which task determines the boundary values for creating partitions?

Creating a partition function Creating a partition scheme Creating a clustered index Creating nonclustered index

Answer:

Creating a partition function

Trang 12

1 d sp_rename

2 c It is used to enable the CLR integration feature in the database

3 b Enterprise Edition

4 c Clustered index

5 a Creating a partition function

Trang 13

1 Which of the following is true about renaming a view?

a A view is renamed by using the sp_renameview procedure

b A view can only be renamed by the owner of the database

c A view can be renamed from another database

d A view name must follow the rules for identifiers

2 Michael has created a full-text index on the Author column of the Titles table by

using the following command

CREATE FULLTEXT INDEX ON Titles (Author) KEY INDEX Ix.A

Which of the following is an alternative to the given command to create a full-text

index?

a Right-click the table in the Object Explorer window

Select Full-Text Index->Define Full-Text Index

b Right-click the database in the Object Explorer window

Select Full-Text Index->Define Full-Text Index

c Select the database in the Object Explorer window

Select Full-Text Index->Define Full-Text Index

d Select the table in the Object Explorer window

Select Full-Text Index->Define Full-Text Index

3 Which population method should be used first on a table after creating a full-text

index?

a Change tracking-based population method

b Incremental population method

c Full population method

d Incremental timestamp-based population method

4 Harry has populated a table that is full-text indexed After a month, Harry wants to

update the new records from the base table to the full-text indexed table Which

population method should Harry use?

a Change tracking-based population method

b Incremental population method

Trang 14

statements together

d Sam cannot create a batch to add new columns in the table

6 You are using the TRY…CATCH construct to execute a set of statements Which system function returns the name of the stored procedure or trigger in which the error has occurred?

7 Which RAISERROR severity level transfers the control from the TRY block to the CATCH block?

a 11 to 16

b 11 to 19

c 10 to 19

d 10 to 16

8 Which of the following is an invalid statement to execute a procedure named

myproc?

9 Consider the following code snippet:

CREATE PROCEDURE myproc @pr1 int, @pr2 char(50) OUTPUT, @pr3 int OUTPUT

AS

BEGIN

………

Trang 15

c Return parameter data type and optional name

d Output parameter name and data type

Solutions

1 A view name must follow the rules for identifiers

2 Right-click the table in the Object Explorer window Select Full-Text Index->Define

Full-Text Index

3 Full population method

4 Incremental timestamp-based population method

5 Sam cannot create a batch that alters the table by adding a column and then updates

the same column in the table

7 11 to 19

9 The code creates a procedure named myproc with one input and two output

parameters

10 Output parameter name and data type

Trang 16

Assume that you want to restrict access of data to different users on your tables Data access can be restricted at column level for different users SQL Server allows you to create views to restrict user access Views also help simplify query execution when the query involves retrieving data from multiple tables by applying joins

Discuss the various limitations of views

Instructor Inputs

You can conduct the discussion as follows:

„ Discuss the limitations on views while creating a view

„ Move the discussion to the limitations of views that have been created

Solution

While creating views, you should consider the following guidelines:

„ The name of a view must follow the rules for identifiers and must not be the same as that of the table on which it is based

„ A view can be created only if there is a SELECT permission on its base table

„ A view cannot derive its data from temporary tables

„ In a view, ORDER BY cannot be used in the SELECT statement

Views do not maintain a separate copy of the data, but only display the data present in the base tables Therefore, you can modify the base tables by modifying the data in the view However, the following restrictions exist while inserting, updating, or deleting data

through views:

„ You cannot modify data in a view if the modification affects more than one underlying table However, you can modify data in a view if the modification affects only one table at a time

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

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

TÀI LIỆU LIÊN QUAN