ADO.NET Provider for Amazon DynamoDB

Build 21.0.7927

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "AWS Access Key=xxx;AWS Secret Key=xxx;Domain=amazonaws.com;AWS Region=OREGON;";

using (AmazonDynamoDBConnection connection = new AmazonDynamoDBConnection(connectionString)) {
  AmazonDynamoDBCommand cmd = new AmazonDynamoDBCommand("SELECT Id, Name INTO [csv://Account.txt] FROM [Account] WHERE FirstName = 'Bob' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "AWS Access Key=xxx;AWS Secret Key=xxx;Domain=amazonaws.com;AWS Region=OREGON;" 

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

C#

String connectionString = "AWS Access Key=xxx;AWS Secret Key=xxx;Domain=amazonaws.com;AWS Region=OREGON;";

using (AmazonDynamoDBConnection connection = new AmazonDynamoDBConnection(connectionString)) {
  AmazonDynamoDBCommand cmd = new AmazonDynamoDBCommand("SELECT * INTO [Account] IN [csv://filename=c:/Account.csv;delimiter=tab] FROM [Account] WHERE FirstName <> 'Bob'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "AWS Access Key=xxx;AWS Secret Key=xxx;Domain=amazonaws.com;AWS Region=OREGON;" 

Using connection As New AmazonDynamoDBConnection(connectionString)
  Dim cmd As New AmazonDynamoDBCommand("SELECT * INTO [Account] IN [csv://filename=c:/Account.csv;delimiter=tab] FROM [Account] WHERE FirstName <> 'Bob'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7927