sql - create a temp table with serial/auto increment column -


good day trying create temp table auto increment column. have tried various versions of following, not getting work.

create temp table aatemp1 (id serial, (select unnest (string_to_array('388c45f-998d-4d9c-b59a-bd37b70bba7a', '-')))); 

you can't combine "static" column definitions , select that.

you need in 2 steps:

create temp table aatemp1  (   id serial,    some_value text );  insert aatemp1(some_value) select unnest (string_to_array('388c45f-998d-4d9c-b59a-bd37b70bba7a', '-')); 

if want have sequential number in temp table, this:

create temp table aatemp1 select row_number() on (order null) id,         t.* (    select unnest (string_to_array('388c45f-998d-4d9c-b59a-bd37b70bba7a', '-')) ) t; 

(but not generate "new" ids when insert more rows)


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -