Reputation: 62
I am creating my first (!) database, and I have run into an issue that I cannot seem to locate the answer for.
I have put an "added on" field in a table (among other things ofc), and since I'm the one adding it, I want to put the same date in the entire column. The idea is that if there is a new item added at a later date, it will have that date, but the data initially populated should all have the same date.
How? Please don't tell me one row at a time....
Upvotes: 1
Views: 3562
Reputation: 11
You can set default property of that column to any date and it will replicate that for all rows as long as you don't specify any value for that column while inserting and when you want to insert a different value just specify it in the insert statement.
Upvotes: 0
Reputation: 20026
Another possibility in addition to @Nicola's answer is to use the DEFAULT argument in add column.
Upvotes: 0
Reputation: 76880
Just add the column to the table and then run an update query
update yourtable set nameofyournewfield = 'yourdate'
This will update all rows currently in the db, while the new rows will gettheir value (or have the default value you provided)
Upvotes: 6