任务四:尝试在DBO 架构下新建一个对象,并对比着在非DBO 架构下新建对象
步骤:35. 返回到查询窗口(ObjectOwnerCreationPoliciesTestScript.sql 脚本应当处于打开状态). 如果没有打开,请从C:\Manageability Labs\Policy-Based Management 目录将其打开
36. 执行第42-43行:
DROP TABLE TestTable
go
37. 删除数据表以后,尝试再次执行第27-40行:
USE AdventureWorks
go
CREATE TABLE TestTable
(
Col1 int
)
go
SELECT SCHEMA_NAME(schema_id) AS SchemaName, *
FROM sys.objects
WHERE [name] = 'TestTable'
-- note that it is in the default schema of dbo
go
38. 这次将会看到如下信息:
CHICAGO(CHICAGO\Administrator):
Policy 'DBO is not a valid user-defined Schema Name - Base Tables, Views & SPs' has been violated by 'Server/Database[@Name='AdventureWorks2008']/Table[@Name='TestTable' and @Schema='dbo']'.
This transaction will be rolled back.
Policy description: Corporate standard (as of September 2008), is to use schemas for better security and granularity. Objects should not be owned by the dbo - especially if cross-database ownership chaining were to become enabled.'
Additional help: 'Please see our Security Guidelines and Best Practices' : 'http://InternalWebsite/Policies/SQLServerSecurity.htm'.
CHICAGO(CHICAGO\Administrator): Msg 3609, Level 16, State 1, Procedure sp_syspolicy_dispatch_event, Line 50
The transaction ended in the trigger. The batch has been aborted.
CHICAGO(CHICAGO\Administrator): (0 row(s) affected)
39. 现在执行第47-55行:
CREATE TABLE Person.TestTable
(
Col1 int
)
Go
SELECT SCHEMA_NAME(schema_id) AS SchemaName, *
FROM sys.objects
WHERE [name] = 'TestTable'
40. 对象(Person.TestTable) 将可以成功创建,因为它不在dbo 架构中
41. 退出SQL Server Management Studio,本实验结束。