英文:
ALTER DATABASE AUDIT produces a syntax error
问题
我正在尝试将CREATE和DROP命令添加到现有的服务器审计中。
执行以下语句时:
ALTER DATABASE AUDIT SPECIFICATION Powercash_Audit
FOR SERVER AUDIT PowercashAudit
ADD (CREATE, DROP ON SCHEMA::dbo BY PUBLIC)
WITH (STATE = ON);
GO
我收到了以下错误:
Msg 102, Level 15, State 1, Line 38
Incorrect syntax near 'CREATE'.
我还没有修复它,有任何想法吗?
提前感谢,
Alex
英文:
I'm trying to ADD CREATE and DROP commands to an existing SERVER AUDIT.
When executing the following statement :
ALTER DATABASE AUDIT SPECIFICATION Powercash_Audit
FOR SERVER AUDIT PowercashAudit
ADD (CREATE, DROP ON SCHEMA::dbo BY PUBLIC)
WITH (STATE = ON);
GO
I've got the following error :
Msg 102, Level 15, State 1, Line 38
Incorrect syntax near 'CREATE'."
I didn't fix it yet, any ideas ?
Thanks in advance,
Alex
答案1
得分: 2
在SQL Server中,CREATE
和DROP
操作无法直接添加到服务器级别的审计规范中。这些操作仅适用于数据库级别。因此,您需要修改您的脚本以创建一个数据库级别的审计规范,并将其与所需的服务器级别审计相关联。
USE [YourDatabaseName];
CREATE DATABASE AUDIT SPECIFICATION Powercash_Audit
FOR SERVER AUDIT PowercashAudit
ADD (SCHEMA_OBJECT_CHANGE_GROUP)
USE [YourDatabaseName];
ALTER DATABASE AUDIT SPECIFICATION Powercash_Audit
ADD (CREATE, DROP ON SCHEMA::dbo BY PUBLIC)
WITH (STATE = ON);
英文:
In SQL Server, the CREATE
and DROP
actions cannot be directly added to a server-level audit specification. These actions are only applicable at the database level. Therefore, you need to modify your script to create a database-level audit specification and associate it with the desired server-level audit.
USE [YourDatabaseName];
CREATE DATABASE AUDIT SPECIFICATION Powercash_Audit
FOR SERVER AUDIT PowercashAudit
ADD (SCHEMA_OBJECT_CHANGE_GROUP)
USE [YourDatabaseName];
ALTER DATABASE AUDIT SPECIFICATION Powercash_Audit
ADD (CREATE, DROP ON SCHEMA::dbo BY PUBLIC)
WITH (STATE = ON);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论