SELECT*INTO[UiPathArchives].[dbo].[ArchiveAuditEvent] from [AutomationSuite_Platform].[adt].[AuditEvent] where 1=2SELECT * INTO [UiPathArchives].[dbo].[ArchiveAuditEvent] from [AutomationSuite_Platform].[adt].[AuditEvent] where 1 = 2
データをアーカイブします。
監査記録をアーカイブする
DECLARE @NumberOfDaysToKeep INTDECLARE @CurrentDate DATETIME-- Specify the number of days
SET @NumberOfDaysToKeep =60-- Archive the list of audit event records that you want to deleteSET @CurrentDate =GetDate()BEGINTRANSACTIONINSERTINTO[UiPathArchives].[dbo].[ArchiveAuditEvent]SELECT[Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],[UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]FROM[adt].[AuditEvent]WHEREDateDiff(day, CreatedOn, @CurrentDate)> @NumberOfDaysToKeep
-- Delete the audit events
DELETEFROM[adt].[AuditEvent]WHEREEXISTS(SELECT1FROM[UiPathArchives].[dbo].[ArchiveAuditEvent]WHERE Id =[adt].[AuditEvent].[Id])COMMITTRANSACTIONDECLARE @NumberOfDaysToKeep INT
DECLARE @CurrentDate DATETIME
-- Specify the number of days
SET @NumberOfDaysToKeep = 60
-- Archive the list of audit event records that you want to delete
SET @CurrentDate = GetDate()
BEGIN TRANSACTION
INSERT INTO [UiPathArchives].[dbo].[ArchiveAuditEvent]
SELECT
[Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
[UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
FROM [adt].[AuditEvent]
WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
-- Delete the audit events
DELETE FROM [adt].[AuditEvent]
WHERE EXISTS (SELECT 1 FROM [UiPathArchives].[dbo].[ArchiveAuditEvent] WHERE Id = [adt].[AuditEvent].[Id])
COMMIT TRANSACTION
古いデータは、次のクエリを使用すると、削除される前にこれらのアーカイブにコピーされます。
テーブルからデータを削除します。
重要: 次のスクリプトを実行する前に、使用する環境に合わせたスクリプトにしてください。
監査イベント
declare @NumberOfDaysToKeep int
declare @CurrentDate datetime
-- Specify the number of days
SET @NumberOfDaysToKeep =60-- Create temporary table with the list of audit event records that you want to deleteSET @CurrentDate =GetDate()SELECT[Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],[UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]INTO #TempAuditRecordsToDelete
FROM[adt].[AuditEvent]WHEREDateDiff(day, CreatedOn, @CurrentDate)> @NumberOfDaysToKeep
-- Review the audit event records to be deleted
SELECT*FROM #TempAuditRecordsToDelete
-- Delete the audit events
BEGINTRANSACTIONDELETEFROM[adt].[AuditEvent]WHEREEXISTS(SELECT1FROM #TempAuditRecordsToDelete WHERE Id =[adt].[AuditEvent].[Id])DROPTABLE #TempAuditRecordsToDelete
COMMITTRANSACTIONdeclare @NumberOfDaysToKeep int
declare @CurrentDate datetime
-- Specify the number of days
SET @NumberOfDaysToKeep = 60
-- Create temporary table with the list of audit event records that you want to delete
SET @CurrentDate = GetDate()
SELECT
[Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
[UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
INTO #TempAuditRecordsToDelete
FROM [adt].[AuditEvent]
WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
-- Review the audit event records to be deleted
SELECT * FROM #TempAuditRecordsToDelete
-- Delete the audit events
BEGIN TRANSACTION
DELETE FROM [adt].[AuditEvent]
WHERE EXISTS (SELECT 1 FROM #TempAuditRecordsToDelete WHERE Id = [adt].[AuditEvent].[Id])
DROP TABLE #TempAuditRecordsToDelete
COMMIT TRANSACTION
select * into [UiPathIdentityArchives].[dbo].[ArchiveUserLoginAttempts] from [AutomationSuite_Platform].[identity].[UserLoginAttempts] where 1=2select * into [UiPathIdentityArchives].[dbo].[ArchiveUserLoginAttempts] from [AutomationSuite_Platform].[identity].[UserLoginAttempts] where 1=2
古いデータは、次のクエリを使用すると、削除される前にこれらのアーカイブにコピーされます。
テーブルからデータを削除します。
重要: 次のスクリプトを実行する前に、使用する環境に合わせたスクリプトにしてください。
ユーザー ログインの試行
たとえば、60 日を経過したログイン試行を削除するには、次のクエリを使用します。 手動で実行することも、スケジュール設定することもできます
SQL Server ジョブで
declare @NumberOfDaysToKeep int
set @NumberOfDaysToKeep =60ifOBJECT_ID('[UiPathIdentityArchives].[dbo].[UserLoginAttemps]')=NULL
begin select * into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] from [identity].UserLoginAttempts where 1=2 end
begin transaction
set identity_insert [UiPathIdentityArchives].[dbo].[UserLoginAttemps] on
insert into [UiPathIdentityArchives].[dbo].[UserLoginAttemps]([Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName])
select [Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName]
from [identity].UserLoginAttempts where DateDiff(day, CreationTime,GetDate())> @NumberOfDaysToKeep
delete from [identity].UserLoginAttempts where DateDiff(day, CreationTime,GetDate())> @NumberOfDaysToKeep
commit transactiondeclare @NumberOfDaysToKeep int
set @NumberOfDaysToKeep = 60
if OBJECT_ID('[UiPathIdentityArchives].[dbo].[UserLoginAttemps]') = NULL
begin select * into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] from [identity].UserLoginAttempts where 1=2 end
begin transaction
set identity_insert [UiPathIdentityArchives].[dbo].[UserLoginAttemps] on
insert into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] ([Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName])
select [Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName]
from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
delete from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
commit transaction
Automation Suite の Process Mining には自動データベース クリーンアップ機能が組み込まれており、最適な効率とパフォーマンスを確保します。 これにより、不要なデータを定期的に削除し、リソースを解放するための手動操作を必要とせずに、データベースをクリーンアップして機能させることができます。