그렇게하는 동안, 시리얼은 각 삽입의 번호를 건너 뜁니다
,
는 PLZ이 문제를 해결하는 데 도움이 시리얼 컬럼에 숫자를 건너 뜁니다 ... 모든, 그것은 id 컬럼에 숫자를 건너 뜁니다 삽입 나를 PLZ이 문제를 해결하기위한삽입 - 내가 삽입에 "unnest"기능을 사용하려고
mydb=# \d tab1
Table "public.tab1"
Column | Type | Modifiers
--------+---------+---------------------------------------------------
id | integer | not null default nextval('tab1_id_seq'::regclass)
col1 | integer |
col2 | integer |
Indexes:
"tab1_pkey" PRIMARY KEY, btree (id)
mydb=# insert into tab1(id,col1,col2) values (nextval('tab1_id_seq'),1,unnest(array[4,5]));
INSERT 0 2
mydb=# select * from tab1;
id | col1 | col2
----+------+------
1 | 1 | 4
2 | 1 | 5
(2 rows)
mydb=# insert into tab1(id,col1,col2) values (nextval('tab1_id_seq'),2,unnest(array[4,5]));
INSERT 0 2
mydb=# select * from tab1;
id | col1 | col2
----+------+------
1 | 1 | 4
2 | 1 | 5
4 | 2 | 4
5 | 2 | 5
(4 rows)
mydb=# insert into tab1(col1,col2) values(2,unnest(array[4,5]));
INSERT 0 2
mydb=# select * from tab1;
id | col1 | col2
----+------+------
1 | 1 | 4
2 | 1 | 5
4 | 2 | 4
5 | 2 | 5
7 | 2 | 4
8 | 2 | 5
(6 rows)
mydb=# insert into tab1(col2) values(unnest(array[4,5]));
INSERT 0 2
mydb=# select * from tab1;
id | col1 | col2
----+------+------
1 | 1 | 4
2 | 1 | 5
4 | 2 | 4
5 | 2 | 5
7 | 2 | 4
8 | 2 | 5
10 | | 4
11 | | 5
(8 rows)
mydb=# select nextval('tab1_id_seq');
nextval
---------
13
(1 row)
...
답장을 보내 주셔서 감사합니다. 빠른 답변 주셔서 감사합니다. – MAHI