> ## Documentation Index
> Fetch the complete documentation index at: https://rpa.bazhuayu.com/helpcenter/llms.txt
> Use this file to discover all available pages before exploring further.

# 执行SQL语句

## 指令说明

**描述：** 在指定数据库中，执行Insert、Update、Delete等SQL语句

## 参数说明

<Tabs>
  <Tab title="常规">
    <img src="https://mintcdn.com/bazhuayu-rpa-docs/At1Bhn6G7IYQARg7/helpcenter/commands/database/images/executesqlcommand-05.png?fit=max&auto=format&n=At1Bhn6G7IYQARg7&q=85&s=6ba6ab1585fe0f0e75fb6b6a965ee63c" alt="执行SQL语句指令参数面板" width="645" height="442" data-path="helpcenter/commands/database/images/executesqlcommand-05.png" />

    | 参数          | 说明                  |
    | ----------- | ------------------- |
    | **数据库对象**   | 选择已经创建好的数据库对象       |
    | **SQL语句**   | 输入要对数据库对象执行的SQL语句   |
    | **超时秒数（s）** | 设置执行SQL语句的最大超时时间（秒） |
  </Tab>

  <Tab title="高级">
    本指令暂无高级参数。
  </Tab>
</Tabs>

## 使用示例

<img src="https://mintcdn.com/bazhuayu-rpa-docs/At1Bhn6G7IYQARg7/helpcenter/commands/database/images/executesqlcommand-04.png?fit=max&auto=format&n=At1Bhn6G7IYQARg7&q=85&s=73bd163de404029617ec7936b09722b6" alt="执行SQL语句使用示例" width="846" height="293" data-path="helpcenter/commands/database/images/executesqlcommand-04.png" />

**该流程执行逻辑：**

使用【连接数据库】配置Mysql连接，创建数据库对象，并保存到数据库对象

使用【执行SQL语句】在数据库对象中执行sql 语句"INSERT INTO userinfo (userid, username, phone)VALUES (1, '张三', '11111');"

使用【查询数据库】执行查询语句"select \* from userinfo;"，将结果保存到数据库表格数据

使用【导出数据表格】导出数据库表格为Excel文件，并定义表格Sheet页为表1

使用【关闭数据库】指令关闭数据库连接

### 效果展示

<img src="https://mintcdn.com/bazhuayu-rpa-docs/At1Bhn6G7IYQARg7/helpcenter/commands/database/images/executesqlcommand-02.png?fit=max&auto=format&n=At1Bhn6G7IYQARg7&q=85&s=60ab98da6418c7bac170a3688f2279a6" alt="执行SQL语句效果展示" width="219" height="42" data-path="helpcenter/commands/database/images/executesqlcommand-02.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/At1Bhn6G7IYQARg7/helpcenter/commands/database/images/executesqlcommand-03.png?fit=max&auto=format&n=At1Bhn6G7IYQARg7&q=85&s=4b8ee96ba4de25d8383004325379176b" alt="执行SQL语句效果展示" width="844" height="285" data-path="helpcenter/commands/database/images/executesqlcommand-03.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/At1Bhn6G7IYQARg7/helpcenter/commands/database/images/executesqlcommand-01.png?fit=max&auto=format&n=At1Bhn6G7IYQARg7&q=85&s=d49ad3de91b35a126328e38ce3c4196f" alt="执行SQL语句效果展示" width="233" height="47" data-path="helpcenter/commands/database/images/executesqlcommand-01.png" />

<Info>
  使用指令过程中遇到问题？前往 [八爪鱼RPA 开发者社区问答板块](https://rpa.bazhuayu.com/community/questions) 提问，获取官方与社区帮助。
</Info>
