AdventureWorks 範例資料庫AdventureWorks sample databases

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是平行處理資料倉儲Parallel Data Warehouseyes平行處理資料倉儲Parallel Data Warehouse適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是平行處理資料倉儲Parallel Data Warehouseyes平行處理資料倉儲Parallel Data Warehouse

本文提供下載 AdventureWorks 範例資料庫的直接連結,以及將其還原為 SQL Server 和 Azure SQL Database 的指示。This article provides direct links to download AdventureWorks sample databases, as well as instructions for restoring them to SQL Server and Azure SQL Database.

如需範例的詳細資訊,請參閱 範例 GitHub 存放庫For more information about samples, see the Samples GitHub repository.


下載備份檔案Download backup files

使用這些連結可針對您的案例下載適當的範例資料庫。Use these links to download the appropriate sample database for your scenario.

  • OLTP 資料適用于最常見的線上交易處理工作負載。OLTP data is for most typical online transaction processing workloads.
  • 資料倉儲 (DW) 資料適用于資料倉儲工作負載。Data Warehouse (DW) data is for data warehousing workloads.
  • 輕量 (LT) 資料是 OLTP 範例的輕量且精簡的低版本。Lightweight (LT) data is a lightweight and pared down version of the OLTP sample.

如果您不確定所需的專案,請從符合您 SQL Server 版本的 OLTP 版本開始。If you're not sure what you need, start with the OLTP version that matches your SQL Server version.

OLTPOLTP 資料倉儲Data Warehouse 輕量型Lightweight
AdventureWorks2019 .bakAdventureWorks2019.bak AdventureWorksDW2019 .bakAdventureWorksDW2019.bak AdventureWorksLT2019 .bakAdventureWorksLT2019.bak
AdventureWorks2017 .bakAdventureWorks2017.bak AdventureWorksDW2017 .bakAdventureWorksDW2017.bak AdventureWorksLT2017 .bakAdventureWorksLT2017.bak
AdventureWorks2016 .bakAdventureWorks2016.bak AdventureWorksDW2016 .bakAdventureWorksDW2016.bak AdventureWorksLT2016 .bakAdventureWorksLT2016.bak
AdventureWorks2016_EXT .bakAdventureWorks2016_EXT.bak AdventureWorksDW2016_EXT .bakAdventureWorksDW2016_EXT.bak N/AN/A
AdventureWorks2014 .bakAdventureWorks2014.bak AdventureWorksDW2014 .bakAdventureWorksDW2014.bak AdventureWorksLT2014 .bakAdventureWorksLT2014.bak
AdventureWorks2012 .bakAdventureWorks2012.bak AdventureWorksDW2012 .bakAdventureWorksDW2012.bak AdventureWorksLT2012 .bakAdventureWorksLT2012.bak
AdventureWorks2008R2 .bakAdventureWorks2008R2.bak AdventureWorksDW2008R2 .bakAdventureWorksDW2008R2.bak N/AN/A

您可以直接在 GitHub 上找到其他檔案:Additional files can be found directly on GitHub:

還原至 SQL ServerRestore to SQL Server

您可以使用檔案 .bak 將範例資料庫還原至 SQL Server 實例。You can use the .bak file to restore your sample database to your SQL Server instance. 您可以使用 RESTORE (transact-sql) 命令,或使用 SQL Server Management StudioAzure Data Studio中的圖形化介面 (GUI) 。You can do so using the RESTORE (Transact-SQL) command, or using the graphical interface (GUI) in SQL Server Management Studio or Azure Data Studio.

如果您不熟悉如何使用 SQL Server Management Studio (SSMS) ,可以看到 [連接 & 查詢] 以開始使用。If you're not familiar using SQL Server Management Studio (SSMS), you can see connect & query to get started.

若要在 SQL Server Management Studio 中還原資料庫,請遵循下列步驟:To restore your database in SQL Server Management Studio, follow these steps:

  1. .bak從 [下載備份檔案] 區段中提供的其中一個連結下載適當的檔案。Download the appropriate .bak file from one of links provided in the download backup files section.

  2. 將檔案移 .bak 至 SQL Server 的備份位置。Move the .bak file to your SQL Server backup location. 這會根據您的安裝位置、實例名稱和 SQL Server 版本而有所不同。This varies depending on your installation location, instance name and version of SQL Server. 例如,SQL Server 2019 預設實例的預設位置是:For example, the default location for a default instance of SQL Server 2019 is:

    C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup.C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup.

  3. 開啟 SQL Server Management Studio (SSMS) 並連接到中的 SQL Server。Open SQL Server Management Studio (SSMS) and connect to your SQL Server in.

  4. 以滑鼠右鍵 按一下****物件總管 > 還原資料庫] 中的 [資料庫],以啟動 [還原資料庫]。Right-click Databases in Object Explorer > Restore Database... to launch the Restore Database wizard.

    顯示如何選擇以滑鼠右鍵按一下 [資料庫] 物件總管然後選取 [還原資料庫] 來還原資料庫的螢幕擷取畫面。

  5. 選取 [ 裝置 ],然後選取省略號 ( ... ) 選擇裝置。Select Device and then select the ellipses (...) to choose a device.

  6. 選取 [ 新增 ],然後選擇 .bak 您最近移至這個位置的檔案。Select Add and then choose the .bak file you recently moved to this location. 如果您將檔案移到這個位置,但卻無法在嚮導中看到它,這通常表示許可權問題-SQL Server 或登入 SQL Server 的使用者沒有此資料夾中此檔案的許可權。If you moved your file to this location but you're not able to see it in the wizard, this typically indicates a permissions issue - SQL Server or the user signed into SQL Server does not have permission to this file in this folder.

  7. 選取 [確定] 以確認您的資料庫備份選項,然後關閉 [ 選取備份裝置 ] 視窗。Select OK to confirm your database backup selection and close the Select backup devices window.

  8. 核取 [檔案] 索引 標籤,在 [還原資料庫] 嚮導中確認 還原 的位置和檔案名符合您預期的位置和檔案名。Check the Files tab to confirm the Restore as location and file names match your intended location and file names in the Restore Database wizard.

  9. 選取 [確定] 以還原您的資料庫。Select OK to restore your database.

    顯示 [還原資料庫] 視窗的螢幕擷取畫面,其中已醒目提示要還原的備份組,並已呼叫 [確定] 選項。

如需還原 SQL Server 資料庫的詳細資訊,請參閱 使用 SSMS 還原資料庫備份For more information on restoring a SQL Server database, see Restore a database backup using SSMS.

部署至 Azure SQL DatabaseDeploy to Azure SQL Database

您有兩個選項可查看範例 Azure SQL Database 資料。You have two options to view sample Azure SQL Database data. 當您建立新的資料庫時,可以使用範例,也可以使用 SQL Server Management Studio (SSMS) ,將資料庫從 SQL Server 直接部署到 Azure。You can use a sample when you create a new database, or you can deploy a database from SQL Server directly to Azure using SQL Server Management Studio (SSMS).

若要改為取得 Azure SQL 受控執行個體的範例資料,請參閱 將 World Wide 匯入工具還原至 SQL 受控執行個體To get sample data for Azure SQL Managed Instance instead, see restore World Wide Importers to SQL Managed Instance.

部署新的範例資料庫Deploy new sample database

當您在 Azure SQL Database 中建立新的資料庫時,您可以選擇建立空白資料庫或範例資料庫。When you create a new database in Azure SQL Database, you have the option to create a blank database, or a sample database.

遵循下列步驟以使用範例資料庫來建立新的資料庫:Follow these steps to use a sample database to create a new database:

  1. 連接到您的 Azure 入口網站。Connect to your Azure portal.

  2. 選取導覽窗格左上方的 [ 建立資源 ]。Select Create a resource in the top left of the navigation pane.

  3. 選取 [ 資料庫 ],然後選取 [ SQL Database]。Select Databases and then select SQL Database.

  4. 填寫要求的資訊以建立您的資料庫。Fill in the requested information to create your database.

  5. 在 [ 其他設定 ] 索引標籤上,選擇 [ 範例 ] 作為 [ 資料來源] 底下的現有資料:On the Additional settings tab, choose Sample as the existing data under Data source:

    當您建立 Azure SQL Database 時,請在 Azure 入口網站的 [其他設定] 索引標籤上選擇 [範例] 作為資料來源

  6. 選取 [ 建立 ] 以建立新的 SQL Database,也就是 AdventureWorksLT 資料庫的還原複本。Select Create to create your new SQL Database, which is the restored copy of the AdventureWorksLT database.

從 SQL Server 部署資料庫Deploy database from SQL Server

SQL Server Management Studio 能讓您直接將資料庫部署到 Azure SQL Database。SQL Server Management Studio provides the ability to deploy a database directly to Azure SQL Database. 這個方法目前不會提供資料驗證,因此適用于開發和測試,不應該用於生產環境。This method does not currently provide data validation so is intended for development and testing and should not be used for production.

若要從 SQL Server 將範例資料庫部署至 Azure SQL Database,請遵循下列步驟:To deploy a sample database from SQL Server to Azure SQL Database, follow these steps:

  1. 在 SQL Server Management Studio 中連接到您的 SQL Server。Connect to your SQL Server in SQL Server Management Studio.

  2. 如果您尚未這麼做,請將 範例資料庫還原至 SQL ServerIf you haven't already done so, restore the sample database to SQL Server.

  3. 以滑鼠右鍵按一下您在 [ 將 > > 資料庫部署到 Microsoft Azure SQL Database...] 物件總管工作中還原的資料庫。Right-click your restored database in Object Explorer > Tasks > Deploy Database to Microsoft Azure SQL Database....

    選擇以滑鼠右鍵按一下您的資料庫,然後選取 [工作],將資料庫部署到 Microsoft Azure SQL Database

  4. 依照嚮導連接到 Azure SQL Database 並部署您的資料庫。Follow the wizard to connect to Azure SQL Database and deploy your database.

建立腳本Creation scripts

除了還原資料庫之外,您也可以使用腳本來建立 AdventureWorks 資料庫(不論版本為何)。Instead of restoring a database, alternatively, you can use scripts to create the AdventureWorks databases regardless of version.

您可以使用下列腳本來建立整個 AdventureWorks 資料庫:The below scripts can be used to create the entire AdventureWorks database:

您可以在 GitHub上找到使用腳本的其他相關資訊。Additional information about using the scripts can be found on GitHub.

下一步Next steps

當您還原範例資料庫之後,請使用下列教學課程來開始使用 SQL Server:Once you've restored your sample database, using the following tutorials to get started with SQL Server:

SQL Server 資料庫引擎的教學課程 Tutorials for SQL Server database engine
使用 SQL Server Management Studio (SSMS) 進行連線及查詢 Connect and query with SQL Server Management Studio (SSMS)
使用 Azure Data Studio 連接和查詢Connect and query with Azure Data Studio