I’m working on the first giant update to my website. It has an existing table for posts. If I add on two columns to the table, will I be able to import the old data to the updated table?
EDIT: I meant columns. Whoops.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You mean two columns? If they are nullable then you should be able to import your old data which doesn’t contain these columns. You’ll just need to write your insert statement carefully by making sure to specify the exact columns you are inserting into. This is a good practice and should be done anyway (thanks Bruno for the tip).
Example:
Instead of
If the two new columns are not nullable then you can you try appending some dummy data using literals just to get the insert to work.
Example:
Or you could create a default constraint which will work just as well.