-- 최근 30일간 권한 변경 이력 조회
SELECT
event_time,
user_identity.email AS changed_by,
action_name,
request_params.securable_type,
request_params.securable_full_name,
request_params.principal,
request_params.changes
FROM system.access.audit
WHERE action_name IN (
'grantPermission',
'revokePermission',
'updatePermissions'
)
AND event_time >= current_date() - INTERVAL 30 DAYS
ORDER BY event_time DESC;
-- 미사용 권한 탐지: 90일간 접근하지 않은 테이블의 SELECT 권한
SELECT
g.principal,
g.securable_full_name,
g.privilege,
MAX(a.event_time) AS last_access
FROM system.information_schema.table_privileges g
LEFT JOIN system.access.audit a
ON a.request_params.securable_full_name = g.securable_full_name
AND a.user_identity.email = g.principal
AND a.action_name = 'commandSubmit'
GROUP BY g.principal, g.securable_full_name, g.privilege
HAVING MAX(a.event_time) IS NULL
OR MAX(a.event_time) < current_date() - INTERVAL 90 DAYS;