3

I have two tables, A and B, and I need to copy the values from A into B. I tried an sql like this:

insert into B (UPDATE_FILE, RUN_DATE, CREATED_DATE) 
SELECT UPDATE_FILE, RUN_DATE from A 

My problem is that table A did not have created_date column while in B the created_date is not nullable. How can I set a default value to created_date or the current time with this sql? I am using SQLiteStudio 3.0.6

0

2 Answers 2

5

Try something like this:

insert into B (UPDATE_FILE, RUN_DATE, CREATED_DATE) 
SELECT UPDATE_FILE, RUN_DATE,now() from A 

It will insert current date in the "CREATED_DATE" column.

0
0

You can pass a default date... like this

insert into B (UPDATE_FILE, RUN_DATE, CREATED_DATE) SELECT UPDATE_FILE, RUN_DATE,'any Date' from A

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.