기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
테이블 삭제
다음 코드 조각을 사용하여 테이블을 삭제할 수 있습니다.
- Java
-
public void deleteTable() { System.out.println("Deleting table"); final DeleteTableRequest deleteTableRequest = new DeleteTableRequest(); deleteTableRequest.setDatabaseName(DATABASE_NAME); deleteTableRequest.setTableName(TABLE_NAME); try { DeleteTableResult result = amazonTimestreamWrite.deleteTable(deleteTableRequest); System.out.println("Delete table status: " + result.getSdkHttpMetadata().getHttpStatusCode()); } catch (final ResourceNotFoundException e) { System.out.println("Table " + TABLE_NAME + " doesn't exist = " + e); throw e; } catch (final Exception e) { System.out.println("Could not delete table " + TABLE_NAME + " = " + e); throw e; } }
- Java v2
-
public void deleteTable() { System.out.println("Deleting table"); final DeleteTableRequest deleteTableRequest = DeleteTableRequest.builder() .databaseName(DATABASE_NAME).tableName(TABLE_NAME).build(); try { DeleteTableResponse response = timestreamWriteClient.deleteTable(deleteTableRequest); System.out.println("Delete table status: " + response.sdkHttpResponse().statusCode()); } catch (final ResourceNotFoundException e) { System.out.println("Table " + TABLE_NAME + " doesn't exist = " + e); throw e; } catch (final Exception e) { System.out.println("Could not delete table " + TABLE_NAME + " = " + e); throw e; } }
- Go
-
deleteTableInput := ×treamwrite.DeleteTableInput{ DatabaseName: aws.String(*databaseName), TableName: aws.String(*tableName), } _, err = writeSvc.DeleteTable(deleteTableInput) if err != nil { fmt.Println("Error:") fmt.Println(err) } else { fmt.Println("Table deleted", *tableName) }
- Python
-
def delete_table(self): print("Deleting Table") try: result = self.client.delete_table(DatabaseName=Constant.DATABASE_NAME, TableName=Constant.TABLE_NAME) print("Delete table status [%s]" % result['ResponseMetadata']['HTTPStatusCode']) except self.client.exceptions.ResourceNotFoundException: print("Table [%s] doesn't exist" % Constant.TABLE_NAME) except Exception as err: print("Delete table failed:", err)
- Node.js
-
다음 조각은 JavaScript v3AWSSDK에 를 사용합니다. 클라이언트를 설치하는 방법과 사용량에 대한 자세한 내용은 JavaScript v3AWSSDK용 Timestream Write Client -를 참조하세요.
클래스 DeleteTableCommand 및 도 참조하세요DeleteTable.
import { TimestreamWriteClient, DeleteTableCommand } from "@aws-sdk/client-timestream-write"; const writeClient = new TimestreamWriteClient({ region: "us-east-1" }); const params = { DatabaseName: "testDbFromNode", TableName: "testTableFromNode" }; const command = new DeleteTableCommand(params); try { const data = await writeClient.send(command); console.log("Deleted table"); } catch (error) { if (error.code === 'ResourceNotFoundException') { console.log(`Table ${params.TableName} or Database ${params.DatabaseName} doesn't exist.`); } else { console.log("Delete table failed.", error); throw error; } }
다음 조각은 JavaScript V2 스타일에 를 AWS SDK 사용합니다. 이는 Node.js 샘플 Amazon Timestream의 샘플 애플리케이션을 기반으로 LiveAnalytics 합니다 GitHub
. async function deleteTable() { console.log("Deleting Table"); const params = { DatabaseName: constants.DATABASE_NAME, TableName: constants.TABLE_NAME }; const promise = writeClient.deleteTable(params).promise(); await promise.then( function (data) { console.log("Deleted table"); }, function(err) { if (err.code === 'ResourceNotFoundException') { console.log(`Table ${params.TableName} or Database ${params.DatabaseName} doesn't exists.`); } else { console.log("Delete table failed.", err); throw err; } } ); }
- .NET
-
public async Task DeleteTable() { Console.WriteLine("Deleting table"); try { var deleteTableRequest = new DeleteTableRequest { DatabaseName = Constants.DATABASE_NAME, TableName = Constants.TABLE_NAME }; DeleteTableResponse response = await writeClient.DeleteTableAsync(deleteTableRequest); Console.WriteLine($"Table {Constants.TABLE_NAME} delete request status: {response.HttpStatusCode}"); } catch (ResourceNotFoundException) { Console.WriteLine($"Table {Constants.TABLE_NAME} does not exists"); } catch (Exception e) { Console.WriteLine("Exception while deleting table:" + e.ToString()); } }
테이블 업데이트
테이블 나열