dimanche 13 septembre 2015

Insert empty data not null

I am using a SQLLite Database and I want to copy values from one table to another. So I found this:

INSERT INTO `table1` (`row_id`, `daystamp`, `column1`, `column2`) SELECT `position`, 2015813, `column1`, `column2` FROM `table2`

The problem is that the "table1" has more columns than the four. As result the other columns are null, but I didn't want them to be null. So I add to every column "NOT NULL" and I get the error after exeucting the SQLQuery above:

NOT NULL constraint failed: table1.colum3: INSERT INTO `table1` (`row_id`, `daystamp`, `column1`, `column2`) SELECT `position`, 2015813, `column1`, `column2` FROM `table2`

I want that the cells are empty. How should I do this, without put every column in the query?

Aucun commentaire:

Enregistrer un commentaire