JDBC Driver for Presto

Build 22.0.8479

UPDATE ステートメント

既存のレコードを変更するには、UPDATE ステートメントを使用します。

制限事項

更新はTrino のリリース352 以降でのみサポートされています。

Update 構文

UPDATE 構文はカンマ区切りのカラムをインプットとして取り、SET 句のname-value ペアを新しいカラム値として取ります。

UPDATE <table_name> SET { <column_reference> = <expression> } [ , ... ] WHERE { Id = <expression>  } [ { AND | OR } ... ] 

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
Statement またはPreparedStatement クラスのexecuteUpdate メソッドを使って、データ操作コマンドを実行し影響を受けた行を取得できます。
String cmd = "UPDATE [Hive].[Default].Customers SET Name='Floppy Disks' WHERE Id = ?";
PreparedStatement pstmt = connection.prepareStatement(cmd);
pstmt.setString(1, "1");
int count = pstmt.executeUpdate();
System.out.println(count + " rows were affected");
connection.close();

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8479