insert into test_b (select * from test_a) with different column order
В списке pgsql-general по дате отправления:
| От | Ole Tange |
|---|---|
| Тема | insert into test_b (select * from test_a) with different column order |
| Дата | |
| Msg-id | ce534faa1003290751g6552668fi675e1e42e7cfc525@mail.gmail.com обсуждение |
| Ответы |
Re: insert into test_b (select * from test_a) with different column order
|
| Список | pgsql-general |
I have 2 tables that have the same column names but in different
order. Similar to this:
create table test_a (col_a text, col_b int);
create table test_b (col_b int, col_a text);
insert into test_a values ('abc', 2),( 'def', 3);
I would like to do this:
insert into test_b (select * from test_a);
This fails because the columns in test_b are not in the same order as
test_a. For my use case the tables may get more columns or have
columns removed over time og be recreated in a different order, the
only thing that is given is that the column names in test_a and test_b
always are the same and that the datatype of the named columns are the
same.
Is there a general solution I can use to do the insert?
Regards,
Ole Tange
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера