---
schema_version: "1"
id: 7f8e9ad408d4234c31ed99bb97f410a94b7908863b3cae9bfac043aa94d5c4c2
title: Tableau 数据提取命令行实用工具
collection: tableau
version: next
locale: zh-cn
portal_url: https://docs.salesforce.com/tableau/next/zh-cn/public/desktop/extracting_TDE.md
canonical_url: https://help.tableau.com/v0.0/public/desktop/zh-cn/extracting_TDE.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 07f71e67dd4eed2e021310b960304d37f620c135bda37e031654c96f489edf77
description: Automate extract refresh tasks using the Tableau Data Extract Command-Line Utility.
---
[跳转到主要内容](#main-content)

# Tableau 数据提取命令行实用工具

您可以使用 Tableau 数据提取命令行实用工具自动执行数据提取刷新任务。此实用工具是 Tableau Desktop 附带的一种命令行实用工具，您可以通过其刷新发布的数据提取数据源，或将数据从文件附加到这些数据源。

若要使用 Tableau 数据提取命令行实用工具，需满足以下要求：

- 它在 Windows 上随 Tableau Desktop 一起提供，并且只能在 Windows 系统上运行。
- 它不适用于试用版的 Tableau Desktop。
- 您可以为不使用 Oauth 的数据提取数据源使用该实用工具。
- 您只能使用它来刷新单连接数据源。它不适用于多连接数据源。

**2022 年 10 月已弃用：**由于 Tableau Cloud 中的[多重身份验证](https://help.tableau.com/current/online/zh-cn/to_security_mfa.htm)要求，此实用程序在后续版本中不可用。若要刷新 Tableau Cloud 无法直接访问的数据源或虚拟连接数据，请改用 Tableau Bridge。有关详细信息，请参见[设置 Bridge 刷新计划](https://help.tableau.com/current/online/zh-cn/to_sync_schedule.htm)。  
  
若要使用脚本启动刷新作业，请使用 tabcmd [refreshextracts](https://help.tableau.com/current/server/zh-cn/tabcmd_cmd.htm#refreshextracts-workbookname-or-datasourcename) 或 REST API [运行数据提取刷新任务](https://help.tableau.com/current/api/rest_api/zh-cn/REST/rest_api_ref.htm#run_extract_refresh_task)。

## 运行实用工具

1. 以管理员身份打开命令提示符，并转到 Tableau Desktop bin 目录。例如：
    
    `cd C:\Program Files\Tableau\Tableau 2022.4\bin`
2. 使用下列命令之一，并添加下表中描述的参数。
    
    - `tableau refreshextract`
    - `tableau addfiletoextract`

**注意：**使用此实用工具时，始终要在命令行上或脚本中指定 `tableau`，决不要指定 `tableau.exe`。

**注意：**若要进行故障排除，请在 \\我的 Tableau 存储库\\Logs 文件夹中检查 tableaucom.txt 文件中的日志。

**注意**：在多站点环境中，指定命令将应用于的站点。

## tableau refreshextract 命令的语法和参数

使用 `tableau refreshextract` 可刷新 Tableau Server 或 Tableau Cloud 上的数据提取。刷新数据提取将会使用自上次刷新后对数据源所做的任何修改更新现有数据提取。

要查看此命令的帮助，请在 Windows 命令提示符处键入以下命令：

`tableau help refreshextract`

### 使用参数

- 所有选项都有一个与双连字符结合使用的完整形式（例如，`--server`）。
- 有些选项还有一个与单连字符结合使用的短形式（例如，`-s`）。
- 如果选项的值包含空格，则用引号将选项值引起来。
- 所刷新的数据源必须是原始数据源，而不是数据提取 (`.hyper`)。

### tableau refreshextract 命令选项

<table><colgroup><col style="width: 25%;"><col style="width: 30%;"><col style="width: 45%;"></colgroup><tbody><tr><td><b>短形式</b></td><td><b>完整形式</b></td><td><b>描述</b></td></tr><tr><td>&nbsp;</td><td><code>--source-username &lt;user name&gt;</code></td><td><p>数据源连接的有效用户名。</p><p>将此选项与 <code>--source-password</code> 结合使用，或使用</p><p><code>--original-file</code>，而不是用户名和密码选项。</p><p class="note"><b>注意</b>：在刷新发布的数据提取时必须提供用户和密码，即使最初是利用嵌入式凭据发布数据源的。</p></td></tr><tr><td>&nbsp;</td><td><code>--source-password "&lt;password&gt;"</code></td><td><p>数据源用户的密码。</p></td></tr><tr><td>&nbsp;</td><td><p><code>--original-file &lt;path and file name&gt;</code></p><p>或</p><p><code>--original-file&nbsp;&lt;path and folder name&gt;</code></p></td><td><p>将在服务器上进行刷新的数据源的路径和文件名。例如：<code>--original-file c:\folder\file.csv</code></p><p>若要刷新多文件数据源，请将路径传递到包含数据文件的文件夹。例如：<code>--original-file c:\folder</code>。</p><p>如果文件位于网络共享上，请为路径使用 UNC 格式：<code>\\server\path\filename.csv</code></p></td></tr><tr><td>&nbsp;</td><td><code>--force-full-refresh</code></td><td><p>如果数据源设置为进行增量刷新，请使用此选项强制对数据提取进行完整刷新。如果不包括此选项，则执行增量刷新。并非所有数据源都支持增量刷新。</p></td></tr><tr><td><code>-s &lt;server http address&gt;</code></td><td><code>--server  &lt;URL&gt;</code></td><td><p>在其中发布数据的 Tableau Server 的 URL。</p><p>对于 Tableau Cloud，请指定 <code>https://online.tableau.com</code>。</p></td></tr><tr><td><code>-t &lt;site id&gt;</code></td><td><code>--site &lt;siteid&gt;</code></td><td><p>在多站点环境中，指定命令将应用于的站点。对于 Tableau Cloud，如果您的用户名与一个以上的站点关联，请使用此参数。对于 Tableau Server，如果未指定站点，则使用默认站点。</p><p>站点 ID 独立于站点名称，当您在浏览器中查看站点时，它会显示在 URL 中。例如，如果您登录到 Tableau Cloud 后看到的页面的 URL 是</p><pre xml:space="preserve">https://online.tableau.com/t/vernazza/views</pre><p>站点 ID 是 <i>vernazza</i>。</p></td></tr><tr><td>&nbsp;</td><td><code>--datasource &lt;datasource&gt;</code></td><td><p>发布到 Tableau Server 或 Tableau Cloud 的数据源的名称。</p></td></tr><tr><td>&nbsp;</td><td><code>--project &lt;projectname&gt;</code></td><td><p>数据源所属的项目。如果不包括此选项，则假定为默认项目。</p><p>如果要指定的项目是嵌入在项目分层结构内的子项目，则必须随 <code>--parent-project-path</code> 参数一起使用此参数。</p></td></tr><tr><td>&nbsp;</td><td><code>--parent-project-path path/to/project</code></td><td><p>如果将数据源发布到的项目没有位于项目分层结构的顶层，请随 <code>--project</code> 参数一起使用此参数以指定嵌套项目的路径。</p><p>使用正斜杠字符 (<code>/</code>) 来分隔分层结构中的项目级别。使用反斜杠 (<code>\</code>) 对项目名称中的正斜杠或反斜杠字符进行转义。</p><p>例如，对于顶层“Marketing”下的项目“Social”中名为 Sandbox 的项目：</p><p><code>--project Sandbox --parent-project-path Marketing/Social</code></p></td></tr><tr><td><code>-u &lt;user name&gt;</code></td><td><code>--username &lt;username&gt;</code></td><td><p>有效的 Tableau Server 或 Tableau Cloud 用户。</p></td></tr><tr><td><code>-p "&lt;password&gt;"</code></td><td><code>--password  "&lt;password&gt;"</code></td><td><p>指定的 Tableau Server 或 Tableau Cloud 用户的密码。</p></td></tr><tr><td>&nbsp;</td><td><code>--proxy-username &lt;username&gt;</code></td><td><p>代理服务器的用户名。</p></td></tr><tr><td>&nbsp;</td><td><code>--proxy-password "&lt;password&gt;"</code></td><td><p>代理服务器的密码。</p></td></tr><tr><td><code>-c "&lt;path and file name&gt;"</code></td><td><code>--config-file  "&lt;path and file name&gt;"</code></td><td><p>包含命令配置选项的文件的路径和文件名信息。始终将路径括在双引号内。有关详细信息，请参见下面的<a href="#Using" class="xref">使用配置文件</a>。</p></td></tr></tbody></table>

### tableau refreshextract 示例命令

以下命令可刷新已发布到 Tableau Cloud、名为 CurrentYrOverYrStats 的数据提取。此命令指定以下内容：

- Tableau Cloud 用户和密码。
- Tableau Cloud 站点和项目名称。
- 数据源以及用于登录托管数据源的用户名和密码，在本例中，数据库源由云端数据源提供商（例如 Salesforce.com）托管。

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --source-username database_user@hosted_datasource_provider.com --source-password "db_password"`

若要刷新基于文件的数据源的数据提取，请提供您从中创建数据提取的原始文件路径。如果文件位于网络共享上，请使用 UNC 格式，而不是映射的驱动器。

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --original-file "\\server\path\filename.csv"`

## tableau addfiletoextract 的语法

使用 `tableau addfiletoextract` 将文件内容附加到已发布到 Tableau Server 或 Tableau Cloud 的数据提取。此命令组合两个文件。

如果只想使用最新更改更新现有数据提取，请使用 `refreshextract` 命令。使用 `addfiletoextract` 更新现有数据提取将会复制数据。

要查看此命令的帮助，请在 Windows 命令提示符处键入以下命令：

`tableau help addfiletoextract`

所有选项都有一个与双连字符结合使用的完整形式（例如，`--server`）。有些选项还有一个与单连字符结合使用的短形式（例如，`-s`）。如果选项的值包含空格，则用引号将选项值引起来。

### tableau addfiletoextract 命令选项

<table><tbody><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><b>短形式</b></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><b>完整形式</b></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><b>描述</b></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--file &lt;path and file name&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>包含要追加的数据的数据文件的路径和文件名信息。该文件可来自 Excel、Access、Tableau 数据提取，或者带分隔符的文本文件。它不能受密码保护。如果文件位于网络共享上，请使用 UNC 格式。例如，<code>\\server\path\filename.csv</code></p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-s &lt;server http address&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--server  &lt;URL&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>在其中发布数据的 Tableau Server 的 URL。</p><p>对于 Tableau Cloud，请指定 <code>https://online.tableau.com</code>。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-t &lt;site id&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--site &lt;site id&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>在多站点环境中，指定命令将应用于的站点。对于 Tableau Cloud，如果您的用户名与一个以上的站点关联，则必须包括此参数。对于 Tableau Server，如果未指定站点，则使用默认站点。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--datasource &lt;datasource&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>发布到 Tableau Server 或 Tableau Cloud 的数据源的名称。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--project &lt;projectname&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>数据源所属的项目。如果不包括此选项，则假定为默认项目。</p><p>如果要指定的项目是嵌入在项目分层结构内的子项目，则必须随 <code>--parent-project-path</code> 参数一起使用此参数。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--parent-project-path path/to/project</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>如果将数据源发布到的项目没有位于项目分层结构的顶层，请随 <code>--project</code> 参数一起使用此参数以指定嵌套项目的路径。</p><p>使用正斜杠字符 (<code>/</code>) 来分隔分层结构中的项目级别。使用反斜杠 (<code>\</code>) 对项目名称中的正斜杠或反斜杠字符进行转义。</p><p>例如，对于顶层“Marketing”下的项目“Social”中名为 Sandbox 的项目：</p><p><code>--project Sandbox --parent-project-path Marketing/Social</code></p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-u &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--username &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>有效的 Tableau Server 或 Tableau Cloud 用户。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-p "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--password  "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>指定的 Tableau Server 或 Tableau Cloud 用户的密码。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--proxy-username &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>代理服务器的用户名。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--proxy-password "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>代理服务器的密码。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyB-Column1-Body1"><code>-c "&lt;path and filename&gt;"</code></td><td class="TableStyle-Basic-Border-BodyB-Column1-Body1"><code>--config-file "&lt;path and filename&gt;"</code></td><td class="TableStyle-Basic-Border-BodyA-Column1-Body1"><p>包含命令配置选项的文件的路径和文件名信息。始终将路径括在双引号内。有关详细信息，请参见下面的<a href="#Using" class="xref">使用配置文件</a>。</p></td></tr></tbody></table>

### tableau addfiletoextract 示例命令

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau addfiletoextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --file "C:\Users\user2\Documents\DataUploadFiles\AprMay.csv"`

## 使用配置文件

可以使用纯文本编辑器（例如记事本或 Text Edit），来创建可用于 `tableau refreshextract` 或 `tableau addfiletoextract` 的配置文件。如果希望在一段时间内定期更新同一数据源，配置文件可能非常有用。指定配置文件后，就无需在每次运行命令时都键入相同的选项。配置文件还有一个优势，那就是不会在命令行上泄漏用户名和密码。

### 创建配置文件

例如，假设您创建了一个名为 config.txt 的文件并将它保存到您的 Documents 文件夹。在该文件中，您包含了下面显示的参数信息。

对于从托管数据源发布到 Tableau Cloud 的数据源（其中**服务器**为 **https://online.tableau.com**）：

`server=https://online.tableau.com   site=vernazza   username=email@domain.com   password=OurPassword   project=New Animations   datasource=CurrentYrOverYrStats   source-username=database_user@hosted_datasource_provider.com   source-password=db_password`

### 在命令行中引用配置文件

创建配置文件后，可以运行 `tableau refreshextract` 或 `tableau addfiletoextract` 命令，指向配置文件，将其作为命令行中使用的唯一选项，并将配置文件的路径括在双引号内。语法如下：

`tableau refreshextract --config-file "<path>"`

例如，若要刷新在[创建配置文件](#Create)部分的示例中指定的数据提取，应运行以下命令（确保在所用 Tableau Desktop 版本的 bin 目录中工作）：

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --config-file "C:\Users\user1\Documents\config.txt"`

### 配置文件的语法差异

用于在配置文件内指定选项的语法与命令行中使用的语法在以下方面有所不同：

- 选项名称不以短横线或连字符开头。
- 可使用等号（不含空格）分隔选项名称和选项值。
- 值不需要（或不允许）用引号引起来，即使它们包含空格也是如此（就像前面示例中的 `project` 选项）。

## 使用 Windows 任务计划程序刷新数据提取

您可将 Windows 任务计划程序与 Tableau 数据提取命令行实用工具结合使用，以便从企业防火墙内自动执行对 Tableau Desktop Public 数据源的定期更新。可将任务配置为每天、每周或每月执行一次，或者在发生特定系统事件后执行。例如，在计算机启动时运行任务。

若要了解详细信息，请参见 Microsoft TechNet 库中的[任务计划程序使用指南](http://technet.microsoft.com/zh-cn/library/cc766428.aspx)页。