I have two tables in one SQLite database. These tables have some columns that are equal, though not in the same order, and there are columns which they do not share. I am looking for a way to move one or more rows from one table (source) to the other (destination), with the data entered into the column corresponding to the source table.
A typical example; starting situation:
Table 1 - row 1 - Name: John; Surname: Doe; Adress: Longstreet 165
Table 2 - row 1 - Id: 1; Surname: Doe; Name: Jane; Age: 25; Adress: Longstreet 165
After moving:
Table 1 - 'empty in this short example'
Table 2 - row 1 - Id: 1; Surname: Doe; Name: Jane; Age: 25; Adress: Longstreet 165
Table 2 - row 2 - Id: ; Surname: Doe, Name: John; Age: ; Adress: Longstreet 165
I have found 2 questions which are similar Copying data from one sqlite db to another & copy data from one table to another, but can only be used when the column names are known or when the datamodel is the same in both tables. Neither is true in my case. I could use Python to find the column names and map each column, but I was wondering if this could be done in SQLite itself.
Any idea's?
Aucun commentaire:
Enregistrer un commentaire