Sie sind auf Seite 1von 11

Simulado para o exame 70-433 MCTS SQL Server 2008 Database Development Parte 1

setembro 8th, 2011 | Add a Comment

Seguindo o informado no ultimo artigo essa a primeira parte de um simulado para o exame 70-433. O exame 70-433 para a certificao MCTS Microsoft SQL Server 2008, Database Development composto de 7 tpicos, um deles o tpico Implementing Tables and Views que corresponde por 14% do exame. Abaixo segue 7 questes simuladas para o exame do tpico Implementing Tables and Views, Leiam Respondam e mais abaixo questes com resposta e explicao. Questo 1 A human resources department database includes a table called Contractors. Applications frequently use the following statement to access rows that were updated after January 1, 2008: SELECT id, name FROM Contractors WHERE expertise = @searchWord AND lastUpdated > 20080101; You must decrease the time it takes for this statement to execute. Which statement should you run? A CREATE INDEX expertise_index ON Contractors (lastUpdated, expertise); B- CREATE INDEX expertise_index ON Contractors (expertise) WHERE lastUpdated > 20080101; C- CREATE INDEX expertise_index ON Contractors(lastUpdated) INCLUDE (expertise); D- CREATE INDEX expertise_index ON Constractors (expertise, lastUpdated);

Questo 2 You have created a table using the following query: CREATE TABLE dbo.Products ( ID int IDENTITY(1,1) NOT NULL, Name nvarchar(200) NOT NULL, Cost decimal(10,2), SalePrice decimal(10,2), CurrentStock bigint, NumberSold bigint) A user needs the following permissions. * SELECT access to the Name and SalePrice columns * SELECT access to available stock (the difference between the CurrentStock and the NumberSold columns) * ALTER access to the Name and SalePrice columns You must grant the permission to meet these requirements without granting extra permissions or restricting how the columns are accessed. What should you do? A- Grant the user SELECT and ALTER permission on a view defined by the query: CREATE VIEW dbo.CustomerProduct AS SELECT Name, SalePrice, (CurrentStock NumberSold) AS AvailableStock FROM dbo.Products; B- Grant the user SELECT permission on the Name, SalePrice, CurrentStock, and NumberSold columns of the table and ALTER permission on the Name and SalePrice columns. C- Create two stored procedures, one to SELECT from the table and one to ALTER the Name and SalePrice columns, and grant the user EXECUTE permission on the procedures. D- Grant the user SELECT permission on a view defined by the query: CREATE VIEW dbo.CustomerProductSelect AS SELECT Name, SalesPrice, (CurrentStock NumberSold) AS AvailableStock FROM dbo.Products; and grant the user ALTER permission on a view defined by the query: CREATE VIEW dbo.CustomerProduct AS SELECT Name, SalePrice FROM dbo.Products;. Questo 3 Your database includes a table called People, which is owned by the user bob. A view called Employees has been created to limit user access to the People table and is owned by the user alice. One of your users has been granted INSERT permission on Employees and been denied INSERT permission on People. When he attempts to insert a row into the Employees view, the query fails. You must fix the problem. What should you do? A- Grant the user INSERT permission on the People table.

B- Grant the owner of the Employees view INSERT permission on the People table. C- Change the owner of the view to bob. D- Grant the owner of the People table SELECT permission on the Employees view. Questo 4 Your company has two Microsoft SQL Server instances named Server1 and Server2 on which to store product information. You have created a table in the SalesDB database on Server1 using the following statement: CREATE TABLE ProductData ( productID int, manufacturerID int CHECK (manufacturerID BETWEEN 1 AND 50000), price decimal (7,2), packageCount bigint, packagePrice AS price * packageCount, CONSTRAINT PK_id PRIMARY KEY (productID, manufacturerID)); You have created a table in the SalesDB database on Server2 using the following statement: CREATE TABLE ProductData ( productID int, manufacturerID int CHECK (manufacturerID BETWEEN 50001 AND 99999), price decimal (9,2), packageCount bigint, packagePrice AS price * packageCount, CONSTRAINT PK_id PRIMARY KEY (productID, manufacturerID)); You have created an index on both tables using the following statement: CREATE INDEX IN_pp ON Products (productID, packagePrice); You use the following statement to create a distributed partitioned view to access the tables: CREATE VIEW Products AS SELECT productID, manufacturerID, price, packageCount, packagePrice FROM Server1.SalesDB.dbo.ProductData UNION ALL SELECT manufacturerID, productID, price, packageCount, packagePrice FROM Server2.SalesDB.dbo.ProductData; This statement returns an error, which you must fix. What should you do?

A- Remove the primary key constraint from both tables. B- Change the second SELECT statement in the view definition to SELECT productID, manufacturerID, price, packageCount, packagePrice. C- Change the data type of the price column in the table on Server2 to decimal (7,2). D- Drop the IN_pp index from both tables. Questo 5 Your database includes a table called Employees, which contains an nvarchar(MAX) column named lastName. You have an existing unique clustered index called id_index on a column named id. One of your users has complained about long query times when using the lastName column in the WHERE clause of a SELECT statement. Which statement should you run? A- ALTER INDEX id_index ON Employees (id, lastName); B- CREATE INDEX name_index ON Employees (lastName); C- CREATE INDEX id_name_index ON Employees (id) INCLUDE (lastName); D- CREATE CLUSTERED INDEX name_index ON Employees (lastName); Questo 6 One of your users has accidentally deleted a row from a table named Products that contains an IDENTITY column named id. When you try to reinsert the same data that was in the deleted row, you receive an error message. What should you do? A- Turn IDENTITY_INSERT on using SQL Server Management Studio (SSMS), and then insert the row. B- Remove the identity property from the id column using SQL Server Management Studio (SSMS), and then insert the row. C- Reseed the id column to match the id of the deleted row, and then insert the row. D- Execute SET IDENTITY_INSERT Products ON;, and then insert the row. Questo 7 You have created a view using the following command: CREATE VIEW dbo.Employee WITH ENCRYPTION AS SELECT Name FROM dbo.HumanResources

WHERE isEmployee = 1 WITH CHECK OPTION; You must prevent other users from copying the view. Which statement should you use? A- ALTER VIEW dbo.Employee AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1 WITH CHECK OPTION; B- ALTER VIEW dbo.Employee WITH ENCRYPTION AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1; C- ALTER VIEW dbo.Employee WITH SCHEMABINDING AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1; D- DENY ALL ON dbo.Employee TO public; GABARITO: Questo 1 A human resources department database includes a table called Contractors. Applications frequently use the following statement to access rows that were updated after January 1, 2008: SELECT id, name FROM Contractors WHERE expertise = @searchWord AND lastUpdated > 20080101; You must decrease the time it takes for this statement to execute. Which statement should you run? A CREATE INDEX expertise_index ON Contractors (lastUpdated, expertise); B- CREATE INDEX expertise_index ON Contractors (expertise) WHERE lastUpdated > 20080101; C- CREATE INDEX expertise_index ON Contractors(lastUpdated) INCLUDE (expertise);

D- CREATE INDEX expertise_index ON Constractors (expertise, lastUpdated); Resposta Correta: B Explicao: CREATE INDEX expertise_index ON Contractors (expertise) WHERE lastUpdated > 20080101; is the best choice because it limits the index to only the rows relevant to the statement in question, which minimizes both the size of the index and the time to search the index. Each of the other indexes decreases execution time, but none of them is the best solution because it could include rows not relevant to the statement in question. Questo 2 You have created a table using the following query: CREATE TABLE dbo.Products ( ID int IDENTITY(1,1) NOT NULL, Name nvarchar(200) NOT NULL, Cost decimal(10,2), SalePrice decimal(10,2), CurrentStock bigint, NumberSold bigint) A user needs the following permissions. * SELECT access to the Name and SalePrice columns * SELECT access to available stock (the difference between the CurrentStock and the NumberSold columns) * ALTER access to the Name and SalePrice columns You must grant the permission to meet these requirements without granting extra permissions or restricting how the columns are accessed. What should you do? A- Grant the user SELECT and ALTER permission on a view defined by the query: CREATE VIEW dbo.CustomerProduct AS SELECT Name, SalePrice, (CurrentStock NumberSold) AS AvailableStock FROM dbo.Products; B- Grant the user SELECT permission on the Name, SalePrice, CurrentStock, and NumberSold columns of the table and ALTER permission on the Name and SalePrice columns. C- Create two stored procedures, one to SELECT from the table and one to ALTER the Name and SalePrice columns, and grant the user EXECUTE permission on the procedures. D- Grant the user SELECT permission on a view defined by the query: CREATE VIEW dbo.CustomerProductSelect AS SELECT Name, SalesPrice, (CurrentStock NumberSold) AS AvailableStock FROM dbo.Products; and grant the user ALTER

permission on a view defined by the query: CREATE VIEW dbo.CustomerProduct AS SELECT Name, SalePrice FROM dbo.Products;. Resposta correta: A Explicao: The view grants users the access they need while denying them access to any other portions of the database. It also provides flexibility for the users to work with the data as they see fit. Granting users permission directly on the columns gives them access to the CurrentStock and NumberSold columns, rather than limiting them to the difference between them. Creating stored procedures can provide users with the access they need while denying them the access they should not have, but doing this provides less flexibility than the view-based solution, so it is not the best method. Using two separate views is not necessary because having ALTER permission on a view does not grant the user ALTER permission on the columns that make up a calculated column. Questo 3 Your database includes a table called People, which is owned by the user bob. A view called Employees has been created to limit user access to the People table and is owned by the user alice. One of your users has been granted INSERT permission on Employees and been denied INSERT permission on People. When he attempts to insert a row into the Employees view, the query fails. You must fix the problem. What should you do? A- Grant the user INSERT permission on the People table. B- Grant the owner of the Employees view INSERT permission on the People table. C- Change the owner of the view to bob. D- Grant the owner of the People table SELECT permission on the Employees view. Resposta Correta: C Explicao: Changing the owner of the view to match the table it accesses allows any users with INSERT permission on the view to insert data through it even if they do not have INSERT permission on the table. Granting users INSERT permission on the table allows them to insert data through the view, but it does not limit their access to the People table. The permissions of the owner of the view do not affect the referenced table, nor do the permissions of the owner of the table affect the view.

Questo 4 Your company has two Microsoft SQL Server instances named Server1 and Server2 on which to store product information. You have created a table in the SalesDB database on Server1 using the following statement: CREATE TABLE ProductData ( productID int, manufacturerID int CHECK (manufacturerID BETWEEN 1 AND 50000), price decimal (7,2), packageCount bigint, packagePrice AS price * packageCount, CONSTRAINT PK_id PRIMARY KEY (productID, manufacturerID)); You have created a table in the SalesDB database on Server2 using the following statement: CREATE TABLE ProductData ( productID int, manufacturerID int CHECK (manufacturerID BETWEEN 50001 AND 99999), price decimal (9,2), packageCount bigint, packagePrice AS price * packageCount, CONSTRAINT PK_id PRIMARY KEY (productID, manufacturerID)); You have created an index on both tables using the following statement: CREATE INDEX IN_pp ON Products (productID, packagePrice); You use the following statement to create a distributed partitioned view to access the tables: CREATE VIEW Products AS SELECT productID, manufacturerID, price, packageCount, packagePrice FROM Server1.SalesDB.dbo.ProductData UNION ALL SELECT manufacturerID, productID, price, packageCount, packagePrice FROM Server2.SalesDB.dbo.ProductData; This statement returns an error, which you must fix. What should you do? A- Remove the primary key constraint from both tables. B- Change the second SELECT statement in the view definition to SELECT productID, manufacturerID, price, packageCount, packagePrice. C- Change the data type of the price column in the table on Server2 to decimal (7,2).

D- Drop the IN_pp index from both tables. Resposta Correta: D Explicao: The IN_pp indexes should be dropped because member tables of distributed partitioned views cannot have indexes created on any computed columns. Using manufacturerID, productID rather than productID, manufacturerID prevents the creation of the view only if manufacturerID and productID have different data types. The existence of a primary key does not prevent the creation of the view so long as the same columns are used for the primary key on both tables. Having a different precision for the price columns does not prevent the view from being created. Questo 5 Your database includes a table called Employees, which contains an nvarchar(MAX) column named lastName. You have an existing unique clustered index called id_index on a column named id. One of your users has complained about long query times when using the lastName column in the WHERE clause of a SELECT statement. Which statement should you run? A- ALTER INDEX id_index ON Employees (id, lastName); B- CREATE INDEX name_index ON Employees (lastName); C- CREATE INDEX id_name_index ON Employees (id) INCLUDE (lastName); D- CREATE CLUSTERED INDEX name_index ON Employees (lastName); Resposta Correta: B Explicao: Creating an index on a column increases query speed for any SELECT statements that use that column. The statement CREATE INDEX name_index ON Employees (lastName); creates the index. ALTER INDEX id_index ON Employees (id, lastName); does not work because a column cannot be added to an existing index using the ALTER INDEX statement. CREATE INDEX id_name_index ON Employees (id) INCLUDE (lastName); increases query speed, but it is not necessary to include the id column.

CREATE CLUSTERED INDEX name_index ON Employees (lastName); does not work because the table already includes a clustered index. Questo 6 One of your users has accidentally deleted a row from a table named Products that contains an IDENTITY column named id. When you try to reinsert the same data that was in the deleted row, you receive an error message. What should you do? A- Turn IDENTITY_INSERT on using SQL Server Management Studio (SSMS), and then insert the row. B- Remove the identity property from the id column using SQL Server Management Studio (SSMS), and then insert the row. C- Reseed the id column to match the id of the deleted row, and then insert the row. D- Execute SET IDENTITY_INSERT Products ON;, and then insert the row. Resposta Correta: D Explicao: SET IDENTITY_INSERT Products ON; allows explicit values to be entered into an identity column for the remainder of the current session or until it is turned off again. SET IDENTITY_INSERT must be set at execution time, so it cannot be set using SSMS. Removing the identity property allows the row to be inserted, but doing this alters the functionality of the database unless the identity property is reinstated with the appropriate seed value. Unless the deleted row was the last row to be inserted, reseeding the id column produces errors in subsequent inserts to the table. Questo 7 You have created a view using the following command: CREATE VIEW dbo.Employee WITH ENCRYPTION AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1 WITH CHECK OPTION; You must prevent other users from copying the view. Which statement should you use? A- ALTER VIEW dbo.Employee AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1 WITH CHECK OPTION;

B- ALTER VIEW dbo.Employee WITH ENCRYPTION AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1; C- ALTER VIEW dbo.Employee WITH SCHEMABINDING AS SELECT Name FROM dbo.HumanResources WHERE isEmployee = 1; D- DENY ALL ON dbo.Employee TO public; Reposta Correta: B Explicao: The WITH ENCRYPTION option of the CREATE VIEW command encrypts the view definition in sys.syscomments so that it cannot be viewed by anyone, even the views owner. The WITH CHECK OPTION option indicates that data entered through the view is validated, but it does not affect changes to the underlining database. It does not affect retrieving the view structure. When a view is created with the WITH SCHEMABINDING option, none of the rows used in the view can be altered without dropping or altering the view first. It does not affect retrieving the view structure. Denying access prevents users from using the view, but it does not keep them from retrieving its structure. Essa foi a primeira de uma serie de questes, aguardem a prximas. por Vagner Riberti fonte Microsoft

Das könnte Ihnen auch gefallen