Search Postgresql Archives

Re: Primary key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 14, 2011 at 10:58 AM, Peter Evens <peter@xxxxxxxxx> wrote:
> hello,
>
> i have a question about the PRIMARY KEY,
>
> how can we let it start from for example 1000 instead of 1?
>
> This is our program:
>
> CREATE TABLE hy3_pack
>
> (
>
> hy3_id serial NOT NULL,
>
> hy3_serie_nummer text NOT NULL,
>
> hy3_barcode text NOT NULL,
>
> hy3_type_vulling text NOT NULL,
>
> hy3_tarra_gewicht text,
>
> hy3_artikel_id numeric NOT NULL,
>
> hy3_refill boolean,
>
> vernietigd boolean,
>
> opmerking text,
>
> CONSTRAINT hy3_pack_pkey PRIMARY KEY (hy3_id)
>
> )
>
> WITH (
>
> OIDS=FALSE
>
> );
>
> ALTER TABLE hy3_pack OWNER TO postgres;
>
> what must i change in my program?
>
> Met vriendelijke groeten,
> Peter Evens
> BANDIT nv/sa
> Nijverheidslaan 1547
> B-3660 Opglabbeek
> België
> Tel. 0032/89/85.85.65
> Fax 0032/89/51.85.47
> peter@xxxxxxxxx

Not sure about SERIAL. In postgreSQL we have sequence database object
("http://www.postgresql.org/docs/9.0/interactive/sql-createsequence.html";).

Perhaps the DDL SQL statements below may help.

CREATE SEQUENCE hy3_pack_seq MINVALUE 1000;
CREATE TABLE hy3_pack
(
hy3_id INTEGER NOT NULL DEFAULT nextval('hy3_pack_seq') -- or hy3_id
BIGINT NOT NULL DEFAULT nextval('hy3_pack_seq')
,hy3_serie_nummer text NOT NULL
,hy3_barcode text NOT NULL
,hy3_type_vulling text NOT NULL
,hy3_tarra_gewicht text
,hy3_artikel_id numeric NOT NULL
,hy3_refill boolean
,vernietigd boolean
,opmerking text
,CONSTRAINT hy3_pack_pkey PRIMARY KEY(hy3_id)
)
;


Allan.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux