リファレンスガイド> TDV SQLのキーワードと構文> 削除
 
DELETE
TDVは、通常のSQLDELETEステートメントをサポートしています。
ビューでのINSERT、UPDATE、およびDELETEも参照してください。
構文
DELETE FROM <table>
[WHERE <criteria>]
備考
WHERE句にはサブクエリを含めることができます。
サブクエリで参照されるすべてのデータベースオブジェクトは、DELETEのターゲットと同じデータソースからのものである必要があります。
INサブクエリはスカラーである場合とそうでない場合があります。
関係演算子によっては、定量化されたサブクエリをスカラーにする必要がある場合があります。
サブクエリが誤った行を参照している場合、予期しないターゲット行が影響を受ける可能性があります。
基になるデータソースにtruncate_table機能が設定されている場合、ヒントuse_truncateおよびtry_truncateをDELETEキーワードとともに使用できます。
例(すべての行の削除)
次の例では、ordersテーブルのすべての行を削除します。
DELETE FROM /shared/examples/ds_orders/orders
例(特定の行の削除)
次の例では、注文テーブルで商品IDが44である行を削除します。
DELETE FROM /shared/examples/ds_orders/orders
WHERE ProductID = 44
例(サブクエリの使用)
次の例では、サブクエリを使用しています。
DELETE FROM /shared/examples/ds_orders/orders
WHERE ProductID IN (SELECT ProductID FROM /shared/examples/ds_orders2/orderdetails)
例(切り捨てのヒントの使用)
次の例では、サブクエリを使用しています。
DELETE {option use_truncate} FROM /shared/examples/ds_orders/orders
 
In this case, the query engine will run TRUNCATE TABLE, if the truncate capability is set for the data source in the capabilities file. If not, an error will be displayed.
 
DELETE {option try_truncate} FROM /shared/examples/ds_orders/orders
 
In this case, the query engine will run TRUNCATE TABLE, if the truncate capability is set for the data source in the capabilities file. If not, DELETE statement will be executed.