php - Add column to table and set all row's values for the column to a specified value
Get the solution ↓↓↓Solution:
Try this
ALTER TABLE myTable ADD lastCheck INT DEFAULT 10
OR you can run an update afterward
UPDATE MyTable SET lastCheck = 10
SQL Fiddle
Answer
Solution:
You Can use:
$query="Update Tablename set Columnname='value'";
Answer
Solution:
This should work for you:
ALTER TABLE myTable ADD COLUMN lastCheck INT DEFAULT 123
This will add new column and set that column value for all records at once to 123. This will not prohibit for this column to have NULL value. Actually, you can even set default to be NULL after doing this:
ALTER TABLE myTable ALTER COLUMN lastCheck DROP DEFAULT
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.