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

# dbListTables

> 列出目标数据库服务器中的表。

export const siteNameShort = "知行之桥";

列出目标数据库服务器中的表。根据配置和目标数据库类型，其中一些参数和输出属性可能不相关。

## 必需的参数

* **driver**：跨平台版本中的 JDBC 驱动程序类名称，或 .NET 版本中的 ADO.NET 提供程序名称。
* **conn**：连接字符串或数据库 URL。

## 可选的参数

* **includesystemtables**：是否包含系统表。允许的值为 `true` 或 `false`。默认值为 `false`。
* **schema**：从中列出表的数据库 Schema 名称。该 Schema 通常称为一组表的 *命名空间*。
* **catalog**：数据库服务器中的 Catalog。这通常称为 *数据库*。如果不提供值，则返回数据库服务器中所有 Catalog 的表。

## 输出属性

* **db:name**：表的名称。
* **db:type**：表的类型。
* **db:schema**：表所属的 Schema。
* **db:catalog**：表所属的 Catalog。这通常称为 *数据库*。

## 示例

在此示例中，目标数据库服务器是 MySQL，目标 Catalog（数据库）是 `sakila`。请注意，连接字符串中没有 `database` 参数：如果在连接字符串中指定了数据库，则不需要 `catalog` 参数。此脚本将目标 Catalog（数据库）的所有属性写入输出文件。

```xml theme={null}
<!-- Initializing the output item -->
<arc:set attr="output.data" />
<!-- Creating the input db item and the necessary attributes -->
<arc:set attr="db.driver" value="cdata.jdbc.mysql.MySQLDriver" />
<arc:set attr="db.catalog" value="sakila" />
<arc:set attr="db.conn" value="jdbc:cdata:mysql:server=localhost;port=3306;user=root;password=Password123;"/>

<arc:call op="dbListTables" in="db" out="results" >
  <!-- adding result data from the operation to an output item that will be pushed out as a file -->
  <arc:set attr="output.data">[output.data]\nTable Name=[results.db:name]\nType=[results.db:type]\nCatalog=[results.db:catalog]
  </arc:set>
</arc:call>

<!-- setting the filename and pushing the file out --> 
<arc:set attr="output.filename" value="results.txt" />
<arc:push item="output" />
```

输出文件具有以下格式：

```
Table Name=address
Type=TABLE
Catalog=sakila
-----
Table Name=category
Type=TABLE
Catalog=sakila
-----
Table Name=city
Type=TABLE
Catalog=sakila
-----
Table Name=country
Type=TABLE
Catalog=sakila
-----
```

只要在安装并运行 {siteNameShort} 的计算机上安装了驱动程序，就可以修改上面的示例以定位其他数据库。针对 .NET 调整此示例时，需要按如下方式更改 `driver` 和 `conn` 输入：

```xml theme={null}
<arc:set attr="db.driver" value="System.Data.CData.MySql" /> 
<arc:set attr="db.conn" value="Server=localhost;Database=sakila;UID=root;Password=Password123;"/>
```
