database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 2977 게시물 읽기
No. 2977
Re: 시퀀스 질문입니다 답변부탁드리겠습니다 (__)
작성자
정재익
작성일
2001-06-19 22:35
조회수
2,067

아마도 site_id 가 primary key 로 설정되어 있는 것 같군요. 그리고 site_id 에 혹시 이미 기존의 값을 가진 row 가 존재하는 것 아닌가요. 그런 생각이 드는군요.

 

select * from crawlsite;

 

하셔서 존재하는 row 가 없는지 확인해 보시기 바랍니다.

 

자동으로 seqeuence 를 증가시키고자 한다면 다음과 같이 그 필드의 값을 무시하고 insert 하시면 됩니다.

 

insert into crawlsite(site_kind, site_cate,....) values (...);

 

(여기서 site_id 라는 필드값이 빠져 있음을 주의하시기 바랍니다.) 이렇게 할 경우 site_id 에는 default 구문에서 정의된 default 값이 삽입됩니다.

 

>>강민철 님께서 쓰시길<<

 

:: Table "crawlsite"

:: Attribute | Type | Modifier

:: ----------------+-----------------------+-------------------------------------------

:: site_id | numeric(5,0) | not null default nextval('SITESEQ'::text)

:: site_kind | numeric(5,0) | not null

:: site_cate | numeric(5,0) | not null

:: site_abbr | character varying(30) | not null

:: site_url | character varying(60) | not null

:: site_name | character varying(60) | not null

:: site_crawlday | numeric(2,0) | not null

:: site_starthour | numeric(2,0) | not null

:: site_endhour | numeric(2,0) | not null

:: site_interval | numeric(3,0) | not null

:: site_language | numeric(5,0) | not null

:: site_quit | numeric(2,0) | not null

:: site_charset | numeric(5,0) | not null

:: Index: crawlsite_pkey

::

:: 테이블이 이런식으로 있을때

:: insert into crawlsite values(NEXTVAL('siteseq'), 1, 0, 'securityfocus', 'securityfocus.com', 'se

:: curityfocus',9,5,23,60,1001,1,3001);

::

:: 이렇게 해주면

:: ERROR: Cannot insert a duplicate key into unique index crawlsite_pkey

:: 이런 에러가 나는군요 site_id 를 자동 증가 시키고 싶은에 방법이 없을까요?

:: 답변 부탁드립니다

[Top]
No.
제목
작성자
작성일
조회
2980있자나요...급질문인데요...
은미
2001-06-20
1635
2982┕>Re: 있자나요...급질문인데요...
정재익
2001-06-20 14:10:02
1919
2979더우신데 수고하시네여...!!!
권혁재
2001-06-20
2007
2981┕>Re: 더우신데 수고하시네여...!!!
정재익
2001-06-20 14:06:58
1946
2975PostgreSQL을 윈도우 98에 설치시 질문 ...
김명수
2001-06-19
1768
2976┕>Re: PostgreSQL을 윈도우 98에 설치시 질문 ...
김일형
2001-06-19 21:44:25
2173
2974시퀀스 질문입니다 답변부탁드리겠습니다 (__)
강민철
2001-06-19
2157
2977┕>Re: 시퀀스 질문입니다 답변부탁드리겠습니다 (__)
정재익
2001-06-19 22:35:05
2067
2978 ┕>Re: Re: 재익님 질문에 답변해주셔서 감사합니다 말씀대로 하니 되는군요 ^^*
강민철
2001-06-20 09:27:48
2069
2968꼭 답변을 부탁합니다.
조용주
2001-06-18
1746
2972┕>Re: 꼭 답변을 부탁합니다.
정재익
2001-06-18 22:04:47
1908
2965jdbc연결이 안되여...ㅡㅡ;
이쁜수정이
2001-06-18
1975
2971┕>Re: jdbc연결이 안되여...ㅡㅡ;
김일형
2001-06-18 22:04:25
2156
2964function에서 Select문이 안먹는 이유가 뭘까요?
김일호
2001-06-18
2177
2970┕>Re: function에서 Select문이 안먹는 이유가 뭘까요?
김일형
2001-06-18 21:56:48
2241
2973 ┕>Re: Re: function에서 Select문이 안먹는 이유가 뭘까요?
김일호
2001-06-19 13:25:03
2221
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다