0

このSQLの最良の方法は何ですか?

A)

update tableName set 
FieldA = (if FieldA = 1301 then null else FieldA endif), 
FieldB = (if FieldB = 1301 then null else FieldB endif)
where Id = 707;

また

B)

update tableName set FieldA = null where Id= 707 and FieldA = 1301;
update tableName set FieldB = null where Id= 707 and FieldB = 1301;

モデル「A」では、機能して問題を解決するSQLが1つしかありません。モデル「B」には、「A」モデルと同じことを行いますが、より読みやすい2つのSQLがあります。

使用するのに最も適切なモデルは何ですか?

4

1 に答える 1

1

次の理由により、Aソリューションの方が優れていると思います。

論理 IO が 1 つ少ない - パフォーマンスが向上

プログラム コードが 2 つ少なく、エラーが少ない

3 サポートと保守のしやすさ

4 このアップデートはかなり読みやすい

于 2011-01-21T17:35:38.653 に答える