> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Audit Logging

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

SQL audit logging gives you detailed information about queries being executed against a table in your cluster. This feature is especially useful when you want to log all queries that are run against a table that contains cardholder data, private health information (PHI), or other personally-identifiable information (PII).

After you enable SQL audit logging for a table, audit logs are sent to the <InternalLink version="stable" path="logging-use-cases#sensitive_access">`SENSITIVE_ACCESS` logging channel</InternalLink>. You can export these logs if your deployment uses CockroachDB Standard or Advanced. For details, refer to <InternalLink path="export-logs">Export Logs From a CockroachDB Standard Cluster</InternalLink> or <InternalLink path="export-logs-advanced">Export Logs From a CockroachDB Advanced Cluster</InternalLink>.

## Enable auditing

Use the <InternalLink version="stable" path="alter-table#experimental_audit">`ALTER TABLE... EXPERIMENTAL_AUDIT`</InternalLink> statement:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> ALTER TABLE {table_name} EXPERIMENTAL_AUDIT SET READ WRITE;
```

Replace <code>{'{table_name}'}</code> with the name of a table.
