---
title: 如何转换 SQL_AUDIT 表内的 request_time 时间-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于 如何转换 SQL_AUDIT 表内的 request_time 时间相关的常见问题和使用技巧，帮助您快速解决 如何转换 SQL_AUDIT 表内的 request_time 时间的难题。
---
切换语言

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

划线反馈

# 如何转换 SQL_AUDIT 表内的 request_time 时间

更新时间：2025-12-08 09:21

适用版本： V3.1.x、V3.2.x、V4.0.x、V4.1.x、V4.2.x、V4.3.x、V4.4.x 内容类型：TechNote  

在 SQL_AUDIT 中 request_time 表示开始执行时间点，单位：微秒，实际查询结果展示不太友好，如何转换成方便观察的结果。

## 解决方法

- MySQL 租户

  使用 `USEC_TO_TIME` 函数将微秒数（usec）转换为 TIMESTAMP 类型的值。

  具体示例如下：

  ```shell
  obclient> select request_id,usec_to_time(request_time),ELAPSED_TIME,QUEUE_TIME,EXECUTE_TIME,query_sql from v$OB_SQL_AUDIT where ELAPSED_TIME >100000 limit 10;

  ```
 - Oracle 租户

  Oracle 租户没有特定的函数可以转换，需要使用自定义函数，可以使用 `to_timestamp('1970-01-01 08:00:00.000','yyyy-mm-dd hh24:mi:ss:ff3') + NUMTODSINTERVAL( request_time/1000000, 'SECOND')` 方式转换。

  具体示例如下：

  ```shell
  obclient> select request_id,(to_timestamp('1970-01-01 08:00:00.000','yyyy-mm-dd hh24:mi:ss:ff3') + NUMTODSINTERVAL(request_time/1000000, 'SECOND')),ELAPSED_TIME,QUEUE_TIME,EXECUTE_TIME,query_sql from Gv$OB_SQL_AUDIT where ELAPSED_TIME >100000 and rownum < 10;

  ```

## 适用版本

OceanBase 数据库所有版本。

上一篇

[truncate table 后插入数据报主键重复的问题](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000006084951)

下一篇

[OceanBase 数据库 V4.2.1 版本中表级恢复恢复一张/组分区数较多的表恢复速度慢问题](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000004049248) ![有帮助](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) 咨询热线
