> ## 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.

# dbListViews

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

export const siteNameShort = "知行之桥";

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

## 必需的参数

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

## 可选的参数

* **includesystemviews**：是否包含系统视图。允许的值为 `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="dbListViews" 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]\nView Name=[results.db:name]\nType=[results.db:type]\nCatalog=[results.db:catalog]\n-----
  </arc:set>
</arc:call>

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

输出文件具有以下格式：

```
View Name=actor_info
Type=VIEW
Catalog=sakila
-----
View Name=customer_list
Type=VIEW
Catalog=sakila
-----
View Name=film_list
Type=VIEW
Catalog=sakila
-----
View Name=nicer_but_slower_film_list
Type=VIEW
Catalog=sakila
-----
View Name=sales_by_film_category
Type=VIEW
Catalog=sakila
-----
View Name=sales_by_store
Type=VIEW
Catalog=sakila
-----
View Name=staff_list
Type=VIEW
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;"/>
```
