Column order does matter so if (and only if) the column orders match you can for example:
There is no good 'shortcut' - you should explicitly list columns for both the table you are inserting into and the query you are using for the source data, eg:
insert into items_verselect * from items where item_id=2;
Or if they don't match you could for example:insert into items_ver(item_id, item_group, name)
select * from items where item_id=2;
but relying on column order is a bug waiting to happen (it can
change, as can the number of columns) - it also makes your SQL harder to
readThere is no good 'shortcut' - you should explicitly list columns for both the table you are inserting into and the query you are using for the source data, eg:
insert into items_ver (item_id, name, item_group)
select item_id, name, item_group from items where item_id=2;
Inga kommentarer:
Skicka en kommentar