Cmdlets for Google Data Catalog

Build 21.0.7930

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;ProjectId=YourProjectId;";

using (GoogleDataCatalogConnection connection = new GoogleDataCatalogConnection(connectionString)) {
  GoogleDataCatalogCommand cmd = new GoogleDataCatalogCommand("SELECT Type, DatasetName INTO [csv://Schemas.txt] FROM [Schemas] WHERE ProjectId = 'bigquery-public-data' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;ProjectId=YourProjectId;" 

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

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;ProjectId=YourProjectId;";

using (GoogleDataCatalogConnection connection = new GoogleDataCatalogConnection(connectionString)) {
  GoogleDataCatalogCommand cmd = new GoogleDataCatalogCommand("SELECT * INTO [Schemas] IN [csv://filename=c:/Schemas.csv;delimiter=tab] FROM [Schemas] WHERE ProjectId = 'bigquery-public-data'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;ProjectId=YourProjectId;" 

Using connection As New GoogleDataCatalogConnection(connectionString)
  Dim cmd As New GoogleDataCatalogCommand("SELECT * INTO [Schemas] IN [csv://filename=c:/Schemas.csv;delimiter=tab] FROM [Schemas] WHERE ProjectId = 'bigquery-public-data'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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