You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql/create-external-table-as-select.md
+14-15Lines changed: 14 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: vvasic-msft
5
5
ms.service: azure-synapse-analytics
6
6
ms.topic: overview
7
7
ms.subservice: sql
8
-
ms.date: 04/15/2020
8
+
ms.date: 02/20/2025
9
9
ms.author: vvasic
10
10
ms.reviewer: whhender
11
11
---
@@ -16,28 +16,31 @@ In this article, you'll learn how to store query results to storage using server
16
16
17
17
## Prerequisites
18
18
19
-
Your first step is to **create a database** where you will execute the queries. Then initialize the objects by executing [setup script](https://github.com/Azure-Samples/Synapse/blob/master/SQL/Samples/LdwSample/SampleDB.sql) on that database. This setup script will create the data sources, database scoped credentials, and external file formats that are used to read data in these samples.
19
+
Your first step is to **create a database** where you'll execute the queries. Then initialize the objects by executing [setup script](https://github.com/Azure-Samples/Synapse/blob/master/SQL/Samples/LdwSample/SampleDB.sql) on that database. This setup script will create the data sources, database scoped credentials, and external file formats that are used to read data in these samples.
20
20
21
21
Follow the instructions in this article to create data sources, database scoped credentials, and external file formats that are used to write data into the output storage.
22
22
23
23
## Create external table as select
24
24
25
-
You can use the CREATE EXTERNAL TABLE AS SELECT (CETAS) statement to store the query results to storage.
25
+
You can use the CREATE EXTERNAL TABLE AS SELECT (CETAS) statement to store the query results to storage.
26
26
27
27
> [!NOTE]
28
-
> Change the first line in the query, i.e., [mydbname], so you're using the database you created.
28
+
> Change these values in the query to reflect your environment:
29
+
> - mydbname - change it to the name of the database you created
30
+
> - storage-account-sas - the [shared access signature](/azure/ai-services/document-intelligence/authentication/create-sas-tokens#generating-sas-tokens) for a storage account where you want to write your results
31
+
> - your-storage-account-name - the name of your storage account where you want to write your results (Make sure you have a container called 'csv' or that you change the name of the container here also)
> You must modify this script and change the target location to execute it again. External tables cannot be created on the location where you already have some data.
75
+
> You must modify this script and change the target location to execute it again. External tables can't be created on the location where you already have some data.
73
76
74
77
## Use the external table
75
78
76
79
You can use the external table created through CETAS like a regular external table.
77
80
78
81
> [!NOTE]
79
-
> Change the first line in the query, i.e., [mydbname], so you're using the database you created.
82
+
> Change the first line in the query, that is, [mydbname], so you're using the database you created.
80
83
81
84
```sql
82
85
USE [mydbname];
@@ -93,14 +96,10 @@ ORDER BY
93
96
94
97
## Remarks
95
98
96
-
Once you store your results, the data in the external table cannot be modified. You cannot repeat this script because CETAS will not overwrite the underlying data created in the previous execution. Vote for the following feedback items if some of these are required in your scenarios, or propose the new ones on Azure feedback site:
97
-
-[Enable inserting new data into external table](https://feedback.azure.com/d365community/forum/9b9ba8e4-0825-ec11-b6e6-000d3a4f07b8)
98
-
-[Enable deleting data from external table](https://feedback.azure.com/d365community/idea/fb5a00c9-0a25-ec11-b6e6-000d3a4f07b8)
99
-
-[Specify partitions in CETAS](https://feedback.azure.com/d365community/idea/e28278db-0a25-ec11-b6e6-000d3a4f07b8)
100
-
-[Specify file sizes and counts](https://feedback.azure.com/d365community/idea/262048b9-0925-ec11-b6e6-000d3a4f07b8)
99
+
Once you store your results, the data in the external table can't be modified. You can't repeat this script because CETAS won't overwrite the underlying data created in the previous execution.
101
100
102
-
The only supported output types are Parquet and CSV. You can vote for the other types on [Azure feedback site](https://feedback.azure.com/d365community/forum/9b9ba8e4-0825-ec11-b6e6-000d3a4f07b8).
101
+
The only supported output types are currently Parquet and CSV.
103
102
104
-
## Next steps
103
+
## Related content
105
104
106
105
For more information on how to query different file types, see the [Query single CSV file](query-single-csv-file.md), [Query Parquet files](query-parquet-files.md), and [Query JSON files](query-json-files.md) articles.
- EXTERNAL DATA SOURCE `sqlondemanddemo` that references demo storage account protected with SAS key, and EXTERNAL DATA SOURCE `nyctlc` that references publicly available Azure storage account on location `https://azureopendatastorage.blob.core.windows.net/nyctlc/`.
0 commit comments