기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
테이블 업데이트
다음 코드 조각을 사용하여 테이블을 업데이트할 수 있습니다.
- Java
-
public void updateTable() { System.out.println("Updating table"); UpdateTableRequest updateTableRequest = new UpdateTableRequest(); updateTableRequest.setDatabaseName(DATABASE_NAME); updateTableRequest.setTableName(TABLE_NAME); final RetentionProperties retentionProperties = new RetentionProperties() .withMemoryStoreRetentionPeriodInHours(HT_TTL_HOURS) .withMagneticStoreRetentionPeriodInDays(CT_TTL_DAYS); updateTableRequest.setRetentionProperties(retentionProperties); amazonTimestreamWrite.updateTable(updateTableRequest); System.out.println("Table updated"); }
- Java v2
-
public void updateTable() { System.out.println("Updating table"); final RetentionProperties retentionProperties = RetentionProperties.builder() .memoryStoreRetentionPeriodInHours(HT_TTL_HOURS) .magneticStoreRetentionPeriodInDays(CT_TTL_DAYS).build(); final UpdateTableRequest updateTableRequest = UpdateTableRequest.builder() .databaseName(DATABASE_NAME).tableName(TABLE_NAME).retentionProperties(retentionProperties).build(); timestreamWriteClient.updateTable(updateTableRequest); System.out.println("Table updated"); }
- Go
-
// Update table. magneticStoreRetentionPeriodInDays := int64(7 * 365) memoryStoreRetentionPeriodInHours := int64(24) updateTableInput := ×treamwrite.UpdateTableInput{ DatabaseName: aws.String(*databaseName), TableName: aws.String(*tableName), RetentionProperties: ×treamwrite.RetentionProperties{ MagneticStoreRetentionPeriodInDays: &magneticStoreRetentionPeriodInDays, MemoryStoreRetentionPeriodInHours: &memoryStoreRetentionPeriodInHours, }, } updateTableOutput, err := writeSvc.UpdateTable(updateTableInput) if err != nil { fmt.Println("Error:") fmt.Println(err) } else { fmt.Println("Update table is successful, below is the output:") fmt.Println(updateTableOutput) }
- Python
-
def update_table(self): print("Updating table") retention_properties = { 'MemoryStoreRetentionPeriodInHours': Constant.HT_TTL_HOURS, 'MagneticStoreRetentionPeriodInDays': Constant.CT_TTL_DAYS } try: self.client.update_table(DatabaseName=Constant.DATABASE_NAME, TableName=Constant.TABLE_NAME, RetentionProperties=retention_properties) print("Table updated.") except Exception as err: print("Update table failed:", err)
- Node.js
-
다음 조각은 JavaScript v3AWSSDK에 를 사용합니다. 클라이언트를 설치하는 방법과 사용량에 대한 자세한 내용은 JavaScript v3AWSSDK용 Timestream Write Client -를 참조하세요.
클래스 UpdateTableCommand 및 도 참조하세요UpdateTable.
import { TimestreamWriteClient, UpdateTableCommand } from "@aws-sdk/client-timestream-write"; const writeClient = new TimestreamWriteClient({ region: "us-east-1" }); const params = { DatabaseName: "testDbFromNode", TableName: "testTableFromNode", RetentionProperties: { MemoryStoreRetentionPeriodInHours: 24, MagneticStoreRetentionPeriodInDays: 180 } }; const command = new UpdateTableCommand(params); try { const data = await writeClient.send(command); console.log("Table updated") } catch (error) { console.log("Error updating table. ", error); }
다음 조각은 JavaScript V2 스타일에 를 AWS SDK 사용합니다. 이는 Node.js 샘플 Amazon Timestream의 샘플 애플리케이션을 기반으로 LiveAnalytics 합니다 GitHub
. async function updateTable() { console.log("Updating Table"); const params = { DatabaseName: constants.DATABASE_NAME, TableName: constants.TABLE_NAME, RetentionProperties: { MemoryStoreRetentionPeriodInHours: constants.HT_TTL_HOURS, MagneticStoreRetentionPeriodInDays: constants.CT_TTL_DAYS } }; const promise = writeClient.updateTable(params).promise(); await promise.then( (data) => { console.log("Table updated") }, (err) => { console.log("Error updating table. ", err); throw err; } ); }
- .NET
-
public async Task UpdateTable() { Console.WriteLine("Updating Table"); try { var updateTableRequest = new UpdateTableRequest { DatabaseName = Constants.DATABASE_NAME, TableName = Constants.TABLE_NAME, RetentionProperties = new RetentionProperties { MagneticStoreRetentionPeriodInDays = Constants.CT_TTL_DAYS, MemoryStoreRetentionPeriodInHours = Constants.HT_TTL_HOURS } }; UpdateTableResponse response = await writeClient.UpdateTableAsync(updateTableRequest); Console.WriteLine($"Table {Constants.TABLE_NAME} updated"); } catch (ResourceNotFoundException) { Console.WriteLine("Table does not exist."); } catch (Exception e) { Console.WriteLine("Update table failed:" + e.ToString()); } }
테이블 설명
테이블 삭제