---
title: "SQL 审核集成 - 开发者中心 ODC V4.2.3 | OceanBase 文档中心"
description: SQL 审核集成 背景信息 ODC V4.2.0 内置了 SQL 检查，用于实现团队协同场景下的数据库安全管控。SQL 检查规范与环境绑定，即同一个环境下的数据源采用同一套 SQL 检查规范。 ODC V4.2.0 允许系统管理员（或者拥有外部集成管理权限的用户）配置外部 SQL 审核系统集成。您可以在 SQL 窗口…
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*lqS5SYzz_YEAAAAAAAAAAAAADiGDAQ/original) 开发者中心 ODCV 4.2.3

# SQL 审核集成

更新时间：2026-04-13 15:31:14

[编辑](https://github.com/oceanbase/odc-doc/edit/V4.2.3/zh-CN/1000.system-integration/300.sql-audit-integration.md)  

## 背景信息

ODC V4.2.0 内置了 SQL 检查，用于实现团队协同场景下的数据库安全管控。SQL 检查规范与环境绑定，即同一个环境下的数据源采用同一套 SQL 检查规范。

ODC V4.2.0 允许系统管理员（或者拥有外部集成管理权限的用户）配置外部 SQL 审核系统集成。您可以在 SQL 窗口规范中引用外部 SQL 审核系统集成，如果在 SQL 窗口规范中已启用外部 SQL 审核集成，则在 SQL 窗口执行 SQL 语句时，会优先调用外部 SQL 审核系统的 API 进行审核。

本文档旨在介绍如何配置和管理审批集成。

## 执行流程

![1](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/1.png)

1. ODC 系统管理员按照 ODC 提供的配置模板启用 SQL 审核集成、设置访问外部 SQL 审核系统的 API 信息，创建 SQL 审核集成。
 2. ODC 系统管理员在 SQL 窗口规范中允许引用 SQL 审核集成。
 3. ODC 用户在 SQL 窗口中执行 SQL 语句时，如果启用了 SQL 审核集成，则会调用外部 SQL 审核系统的 API 发起 SQL 检查请求。

## 配置说明

### 配置方法

| **一级参数名** | **二级参数名** | **三级参数名** | **四级参数名** | **类型** | **默认值** | **说明** |
| --- | --- | --- | --- | --- | --- | --- |
| http | connectTimeoutSeconds | - | - | Integer | 5 | HTTP 请求的连接超时时间，单位：秒 |
| http | socketTimeoutSeconds | - | - | Integer | 30 | HTTP 请求的 Socket 超时时间，单位：秒 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | method | - | Enum | POST | HTTP 请求方法，支持的枚举值：GET \| POST \| PUT \| PATCH |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | url | - | String | <NULL> | HTTP 请求地址 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | headers | - | Map<String, String> | <NULL> | HTTP 请求头 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | queryParameters | - | Map<String, String> | <NULL> | HTTP 请求参数 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | body | type | ENUM | <NULL> | HTTP 请求体的格式，支持的枚举值：FORM_DATA |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | body | content | Object | <NULL> | HTTP 请求体的内容 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | requestEncrypted | - | Boolean | false | HTTP 请求体是否加密 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | requestSuccessExpression | - | String | <NULL> | 根据响应体解析判断请求是否执行成功的表达式，采用 SPEL 语法规范 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | inWhiteListExpression | - | String | <NULL> | 根据响应体解析判断待执行 SQL 是否在白名单中的表达式，采用 SPEL 语法规范 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | inBlackListExpression | - | String | <NULL> | 根据响应体解析判断待执行 SQL 是否在黑名单中的表达式，采用 SPEL 语法规范 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | needReviewExpression | - | String | <NULL> | 根据响应体解析判断待执行 SQL 是否需要审批的表达式，采用 SPEL 语法规范 |
| api | check（用于向 **外部 SQL 审核系统** 发起 **SQL 检查** 请求） | responseEncrypted | - | Boolean | false | HTTP 响应体是否加密 |

### 模板变量

ODC 提供模板变量供用户输入配置参数时引用，引用方式：以 `${parameter_name}` 格式将模版变量拼接到 String 类型的参数中。

支持的模版变量与说明如下：

| **参数名** | **类型** | **生效范围** | **说明** |
| --- | --- | --- | --- |
| odc.site.url | String | SQL 审核集成 | 外部访问 ODC 网站的地址，以 http/https 开始，包含 VIP 地址/域名/端口的网址，且结尾不包含斜杠（/），该变量值由用户配置到系统参数表中。 |
| user.id | Long | SQL 审核集成 | ODC 用户 ID。 |
| user.name | String | SQL 审核集成 | ODC 用户名。 |
| user.account | String | SQL 审核集成 | ODC 用户账户名。 |
| connection.name | String | SQL 审核集成 | 所属数据源名称。 |
| connection.tenant | String | SQL 审核集成 | 所属数据源的租户名。 |
| connection.properties.${key} | String | SQL 审核集成 | 所属数据源的参数（创建连接时设置的 Map<String, String> 格式的参数，${key} 可以为连接参数 Map 中的任意一个 key）。 |
| sql.content | String | SQL审核集成 | 待检查的 SQL 内容。 |
| sql.content.json.array | String | SQL审核集成 | 待检查的 SQL 内容（按分隔符拆分成多个 SQL 语句后，以 JSON 数组格式组织）。 |

### 配置模板

```yaml
# This is a template for integrating a custom SQL interceptor system.
# You must fill in the required fields according to the regulation to adapt to your SQL interceptor system.

# HTTP configurations
http:
  # HTTP connection timeout in second
  connectTimeoutSeconds: 5
  # HTTP socket timeout in second
  socketTimeoutSeconds: 30

# API configurations
api:
  # API configurations used to check the SQL content
  check:
    # Request method, supported values: GET ｜ POST ｜ PUT ｜ PATCH
    method: ~
    # Request URI
    url: ~
    # Request headers, the format is: <key: value>
    headers:
      # Sample of request headers
      Content-Type: application/json;charset=UTF-8
      Accept: application/json
    # Request query parameters, the format is: <key: value>
    queryParameters: ~
    # Request body
    body:
      # Type of request body, supported values: FORM_DATA | RAW
      type: RAW
      # Content of request body, the format is: <String> for RAW type or <key: value> for FORM_DATA type
      # Sample of request content in type of RAW
      content: |-
        {
          "sqlStatement":"${sql.content}"
        }
    # Mark whether the request body is encrypted
    requestEncrypted: false
    # Expression to judge whether the request is successful based on the response body analysis, using the SPEL syntax
    requestSuccessExpression: '[resultCode] == 0'
    # Mark whether the response body is encrypted
    responseEncrypted: false
    # Expression to judge whether the SQL to be executed is in the white list based on the response body analysis, using the SPEL syntax
    inWhiteListExpression: '[checkResult] == 1'
    # Expression to judge whether the SQL to be executed is in the black list based on the response body analysis, using the SPEL syntax
    inBlackListExpression: '[checkResult] == 2'
    # Expression to judge whether the SQL to be executed need review based on the response body analysis, using the SPEL syntax
    needReviewExpression: '[checkResult] == 3'

```

## 前提条件

系统管理员或者拥有外部集成管理权限的用户。

## 新建 SQL 审核集成

1. 在项目协同窗口，单击 **外部集成** > **SQL 审核集成** > **新建 SQL 审核集成**。

   ![2](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/2.png)
 2. 在弹出的 **新建审批集成** 面板中填写或选择以下信息。

   ![3](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/3.png)

   | 信息项 | 说明 |
   | --- | --- |
   | SQL 审核集成名称 | 指定创建的 SQL 审核集成名称。 |
   | SQL 审核集成状态 | 选择启用/停用该SQL 审核集成。 |
   | SQL 审核集成配置 | 编辑 YAML 文件的方式配置审批集成。具体配置方法请参见本文档中的 **配置说明**。 |
 3. 单击 **保存**，完成新建 SQL 审核集成。
 4. 在 SQL 审核集成列表中，可以启用/查看/编辑/删除 SQL 审核集成。

   ![4](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/4.png)
 5. 在 SQL 窗口规范中引用创建的外部 SQL 审核集成。

   ![5](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/5.png)

## 管理 SQL 审核集成

在 SQL 审核集成列表中，单击操作项下的 **查看**/**编辑**/**删除** 按钮，可以查看/编辑/删除 SQL 审核集成信息。

![6](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/odc/420/1500.system-integration/3.sql-audit-integration/4.png)

## 相关文档

- [SQL 窗口规范](https://www.oceanbase.com/docs/common-odc-1000000000468292)
 - [审批集成](https://www.oceanbase.com/docs/common-odc-1000000000468268)
 - [风险等级、风险识别规则与审批流程](https://www.oceanbase.com/docs/common-odc-1000000000468287)

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
