I am trying to imp开发者_JAVA技巧ort from an old database into an updated one.
The databases are basically identical except in one of my tables I added a new column that is NOT NULL.
This obviously makes errors when I used the importer to move the rows over. Is there a way that I can define a default for this new NOT NULL field when doing an Import?
Yes you can add a default constraint to the new column. See this post: Alter column, add default constraint
alter table TableName
add constraint df_ConstraintNAme
default > getutcdate() for [Date]
Two options are:
1) Define a DEFAULT value constraint on the column
2) Temporarily make the column NULL, do the import, then reapply the NOT NULL constraint
精彩评论