ALTER DATABASE AUDIT 产生语法错误。

huangapple go评论55阅读模式
英文:

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中,CREATEDROP操作无法直接添加到服务器级别的审计规范中。这些操作仅适用于数据库级别。因此,您需要修改您的脚本以创建一个数据库级别的审计规范,并将其与所需的服务器级别审计相关联。


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);

huangapple
  • 本文由 发表于 2023年7月13日 18:33:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678399.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定