CData Excel Add-In for Amazon Athena 2019J - Online Help

SELECT INTO ステートメント

CData Excel Add-In for Amazon Athena 2019J - Build 19.0.7354

SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。

SQL クエリを使ったデータのエクスポート

次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。

SELECT Name, TotalDue INTO [csv://Customers.txt] FROM [Customers] WHERE CustomerId = '12345'
ファイルURI で他のフォーマットを指定できます。利用可能な区切り文字はタブ、セミコロン、カンマです。デフォルトはカンマです。次の例は、tab-separated values(TSV)にエクスポートします。
SELECT Name, TotalDue INTO [csv://Customers.txt;delimiter=tab] FROM [Customers] WHERE CustomerId = '12345'

C#

String connectionString = "AccessKey='a123';SecretKey='s123';Region='IRELAND';Database='sampledb';S3StagingDirectory='s3://bucket/staging/';";

using (AmazonAthenaConnection connection = new AmazonAthenaConnection(connectionString)) {
  AmazonAthenaCommand cmd = new AmazonAthenaCommand("SELECT Name, TotalDue INTO [csv://Customers.txt] FROM [Customers] WHERE CustomerId = '12345' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "AccessKey='a123';SecretKey='s123';Region='IRELAND';Database='sampledb';S3StagingDirectory='s3://bucket/staging/';" 

Using connection As New AmazonAthenaConnection(connectionString)
  Dim cmd As New AmazonAthenaCommand("SELECT Name, TotalDue INTO [csv://Customers.txt] FROM [Customers] WHERE CustomerId = '12345'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。

C#

String connectionString = "AccessKey='a123';SecretKey='s123';Region='IRELAND';Database='sampledb';S3StagingDirectory='s3://bucket/staging/';";

using (AmazonAthenaConnection connection = new AmazonAthenaConnection(connectionString)) {
  AmazonAthenaCommand cmd = new AmazonAthenaCommand("SELECT * INTO [Customers] IN [csv://filename=c:/Customers.csv;delimiter=tab] FROM [Customers] WHERE CustomerId = '12345'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "AccessKey='a123';SecretKey='s123';Region='IRELAND';Database='sampledb';S3StagingDirectory='s3://bucket/staging/';" 

Using connection As New AmazonAthenaConnection(connectionString)
  Dim cmd As New AmazonAthenaCommand("SELECT * INTO [Customers] IN [csv://filename=c:/Customers.csv;delimiter=tab] FROM [Customers] WHERE CustomerId = '12345'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

 
 
Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 19.0.7354.0