> ## 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;"/>
```
