Insert the same fixed value into multiple rows Insert the same fixed value into multiple rows sql sql

Insert the same fixed value into multiple rows


You're looking for UPDATE not insert.

UPDATE mytableSET    table_column = 'test';

UPDATE will change the values of existing rows (and can include a WHERE to make it only affect specific rows), whereas INSERT is adding a new row (which makes it look like it changed only the last row, but in effect is adding a new row with that value).


This is because in relational database terminology, what you want to do is not called "inserting", but "UPDATING" - you are updating an existing row's field from one value (NULL in your case) to "test"

UPDATE your_table SET table_column = "test" WHERE table_column = NULL 

You don't need the second line if you want to update 100% of rows.


What you're actually doing is adding rows. To update the content of existing rows use the UPDATE statement:

UPDATE table SET table_column = 'test';