Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f1RD1kx43939 for ; Tue, 27 Feb 2001 08:01:46 -0500 (EST) (envelope-from pgsql-admin-owner@postgresql.org) Received: from smtp1.friendlyworks.com ([151.164.222.222]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1QHEUx06051 for ; Mon, 26 Feb 2001 12:14:31 -0500 (EST) (envelope-from twhite26@kc.rr.com) Received: from dashrendar (unknown [10.1.2.91]) by smtp1.friendlyworks.com (Postfix) with SMTP id 9FDDA1F6F; Mon, 26 Feb 2001 11:14:30 -0600 (CST) Message-ID: <008701c0a018$3559f100$5b02010a@dashrendar> From: "Tim White" To: Cc: References: <20010226150451.3ABA636F9@sitemail.everyone.net> Subject: Re: indexing Date: Mon, 26 Feb 2001 11:18:59 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Archive-Number: 200102/218 X-Sequence-Number: 825 Use an sequence. Add the ID column to your create table statement and set the default to use the next value from the sequence. This will give each entry a unique id number. The syntax would be as follows. create sequence customer_id start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1; create table customer( cust_id int unique not null default nextval('customer_id'), last_name varchar(.... ) This will create a database sequence, and then each time you insert a customer, if you don't specify a cust_id, it will default to the next value in the sequence. Tim White ----- Original Message ----- From: "si" To: Sent: Monday, February 26, 2001 9:04 AM Subject: [ADMIN] indexing > Hi, > > I am new to postgresql, Please can you guide me: > > I have created a table and I would like all the entries to be indexed with a number when the data is entered into the database, hence giving it a new id, every time some data is entered. > > e.g. > > I.D. | Name > 1 | Jack > 2 | Jill > > > Does pgsql do this automatically? or do I have to create a seprate ID field like above, and check the database each time the data is entered and find out the highest number then increment it by 1 and then enter the data with the incremented number. > > If it automatically indexes the names when they are entered in to the database, Please can you show me how to find this index. > > Thanks, > Si > > _____________________________________________________________ > Pick up your email anywhere in the world ---> http://www.remail.net