技术开发 频道

详解SQL Server 2008中创建自定义策略

  (22)删除数据表以后,尝试再次执行第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

   (23)这次将会看到如下信息:

  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)

  (24)现在执行第47-55行:

  CREATE TABLE Person.TestTable

  (

  Col1
int

  )

  
Go

  
SELECT SCHEMA_NAME(schema_id) AS SchemaName, *

  
FROM sys.objects

  
WHERE [name] = 'TestTable'

 

  (25)对象(Person.TestTable) 将可以成功创建,因为它不在dbo 架构中

  (26)退出SQL Server Management Studio,本实验结束。

0
相关文章