I'm playing around with a DB and I'm generating random data to test my frontend. Everytime I wish to set every row a certain way I write
UPDATE medley
SET option = true
At this point Datagrip complains about a missing WHERE clause warning me that my query will update the whole table. But that's what I want!
Is there any generic WHERE clause that I can use like WHERE any
?
For now I've added an ID so that I can WHERE id >= 0
but I was curious if there were any alternatives.
CodePudding user response:
You can add a where clause that is always true:
UPDATE medley
SET option = true
WHERE true;
CodePudding user response:
In DataGrip, there is a settings you need to change. It will prevent you from running these queries and also show you the warning beforehand.
Unsafe query: Update statement without where clause updates all table rows
You will get the error: Error code: 1175 because you are using the safe mode.
To disable the safe mode:
toggle the option in Preferences -> SQL Editor and reconnect