I have tried:
ALTER TABLE MY_TABLE
ADD STAGE INT NOT NULL;
But it gives this error message:
ALTER TABLE only allows columns to be added that can contain nulls or
have a DEFAULT definition specified
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.
As an option you can initially create Null-able column, then update your table column with valid not null values and finally ALTER column to set NOT NULL constraint:
Another option is to specify correct default value for your column:
UPD: Please note that answer above contains
GOwhich is a must when you run this code on Microsoft SQL server. If you want to perform the same operation on Oracle or MySQL you need to use semicolon;like that: