Require column in MySQL safe update

99 Views Asked by At

I have a MySQL server with safe mode enabled (on purpose). Lets say a table looks like this:

id | name | color | id_team
 1 | a    | red   |       1
 2 | b    | red   |       2
 3 | c    | green |       1

When I query

UPDATE table SET name='d';

I get the expected error, that MySQL safe mode is turned on and updating requires a WHERE clause. Allright:

UPDATE table SET name='d' WHERE color='red';

... updates id 1 and 2.

Is it possible to define anything so that updating this table requires column id_team in the WHERE clause, independent from other WHERE-columns?

As you can probably guess, id_team is about permissions and I try to force everyone playing around on MySQL console to ensure that a specific column is set when updating.

1

There are 1 best solutions below

0
Dave Stokes On

You could do something like 'WHERE id > 0' but maybe it is time to turn off safe mode.