Re: [GENERAL] auto-increment field : in a simple way

2012-10-11 Thread Craig Ringer
On 10/11/2012 05:11 PM, Vineet Deodhar wrote: On Thu, Oct 11, 2012 at 12:56 PM, Scott Marlowe mailto:scott.marl...@gmail.com>> wrote: Can't you just add this to your create table: CREATE TABLE tablename ( colname SERIAL , check (colname>0 and colname < 32768)); ); W

Re: [GENERAL] auto-increment field : in a simple way

2012-10-11 Thread JC de Villa
On Thu, Oct 11, 2012 at 5:11 PM, Vineet Deodhar wrote: > On Thu, Oct 11, 2012 at 12:56 PM, Scott Marlowe > wrote: > >> >> Can't you just add this to your create table: >> >> >> CREATE TABLE tablename ( >>colname SERIAL >> , check (colname>0 and colname < 32768)); >> ); >> >> >> > With this co

Re: [GENERAL] auto-increment field : in a simple way

2012-10-11 Thread Vineet Deodhar
On Thu, Oct 11, 2012 at 12:56 PM, Scott Marlowe wrote: > > Can't you just add this to your create table: > > > CREATE TABLE tablename ( >colname SERIAL > , check (colname>0 and colname < 32768)); > ); > > > With this constraint, whether the storage space requirement would reduce? OR Is it just

Re: [GENERAL] auto-increment field : in a simple way

2012-10-11 Thread Craig Ringer
On 10/11/2012 03:04 PM, Vineet Deodhar wrote: user_id smallint NOT NULL DEFAULT nextval('user_id_seq') I'm kind of puzzled about why you'd want to use a serial on a field that can contain at most 65,536 entries anyway. If you're only going to have a max of 65,536 entries then the spa

Re: [GENERAL] auto-increment field : in a simple way

2012-10-11 Thread Scott Marlowe
On Thu, Oct 11, 2012 at 1:04 AM, Vineet Deodhar wrote: > I wish to know regarding auto-increment field. > I learn that the required table definition would be something like -- > > CREATE TABLE tablename ( > colname SERIAL > ); > > For more granular control over the size of field, I need to do

[GENERAL] auto-increment field : in a simple way

2012-10-11 Thread Vineet Deodhar
I wish to know regarding auto-increment field. I learn that the required table definition would be something like -- CREATE TABLE tablename ( colname SERIAL ); For more granular control over the size of field, I need to do the following--- CREATE SEQUENCE user_id_seq; CREATE TABLE user (

Re: [GENERAL] auto-increment column

2011-10-04 Thread Joe Abbate
On 10/04/2011 08:05 AM, Robert Buckley wrote: > Thanks for the replies, > > I have one question regarding this comment... > > "You also need to add a DEFAULT expression and optionally > make the sequence owned by the column:" > > What difference does it make if a table "owns" a sequence of not?.

Re: [GENERAL] auto-increment column

2011-10-04 Thread Boszormenyi Zoltan
Hi, 2011-10-04 14:05 keltezéssel, Robert Buckley írta: > Thanks for the replies, > > I have one question regarding this comment... > > "You also need to add a DEFAULT expression and optionally > make the sequence owned by the column:" > > What difference does it make if a table "owns" a sequence o

Re: [GENERAL] auto-increment column

2011-10-04 Thread Robert Buckley
neral@postgresql.org Gesendet: 13:43 Dienstag, 4.Oktober 2011 Betreff: Re: [GENERAL] auto-increment column 2011-10-04 13:30 keltezéssel, Robert Buckley írta: Hi, > > >I have a column in a table called hist_id with the datatype "integer". When I >created the table I assigned

Re: [GENERAL] auto-increment column

2011-10-04 Thread Boszormenyi Zoltan
2011-10-04 13:30 keltezéssel, Robert Buckley írta: > Hi, > > I have a column in a table called hist_id with the datatype "integer". When I > created > the table I assigned this column the primary key constraint but didn´t make > it an > auto-increment column. > > How could I do this to an the alr

Re: [GENERAL] auto-increment column

2011-10-04 Thread hubert depesz lubaczewski
On Tue, Oct 04, 2011 at 12:30:48PM +0100, Robert Buckley wrote: > Hi, > > I have a column in a table called hist_id with the datatype "integer". When I > created the table I assigned this column the primary key constraint but > didn´t make it an auto-increment column. > > How could I do this to

[GENERAL] auto-increment column

2011-10-04 Thread Robert Buckley
Hi, I have a column in a table called hist_id with the datatype "integer". When I created the table I assigned this column the primary key constraint but didn´t make it an auto-increment column. How could I do this to an the already existing column? I have created the sequence with the followi

Re: [GENERAL] Auto-Increment in Postgres

2011-02-11 Thread David Johnston
and why you are doing that so alternative solutions can be presented. David J From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Adarsh Sharma Sent: Friday, February 11, 2011 6:14 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Auto-Increment

Re: [GENERAL] Auto-Increment in Postgres

2011-02-11 Thread Fredric Fredricson
On 02/11/2011 12:13 PM, Adarsh Sharma wrote: Dear all, I have an Integer column in Postgres database table. Let's say the column has below values : 1 2 3 4 5 6 7 8 9 10 Now if i deleted some rows where id= 3 ,5 and 8 or it have these type of data then The data look like as : 1 2 4 6

Re: [GENERAL] Auto-Increment in Postgres

2011-02-11 Thread Thom Brown
On 11 February 2011 11:13, Adarsh Sharma wrote: > Dear all, > > > I have an Integer column in Postgres database table. Let's say the column > has below values : > > > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > > > Now if i deleted some rows where id= 3 ,5 and 8  or it have these type of > data then

[GENERAL] Auto-Increment in Postgres

2011-02-11 Thread Adarsh Sharma
Dear all, I have an Integer column in Postgres database table. Let's say the column has below values : 1 2 3 4 5 6 7 8 9 10 Now if i deleted some rows where id= 3 ,5 and 8 or it have these type of data then The data look like as : 1 2 4 6 7 9 10 I want to have it id's as 1 2 3 4 5 6

Re: [GENERAL] auto-increment in a view

2009-09-03 Thread Willy-Bas Loos
> Just a wild notion, but would the generate_series function be any use to > you? Good idea, but i can't get it to work. create or replace view testview3 as ( select generate_series(1,(select count(*) from test group by "value")), value from test group by value); select * from testview3 limit 5;

Re: [GENERAL] auto-increment in a view

2009-09-03 Thread Adam Rich
Willy-Bas Loos wrote: Hi, I'm trying to figure out to generate a auto-increment column in a view. There is no physical column to base it on, the view contains a group by clause, which renders that impossible. In a normal query i can create a sequence for that purpouse and drop it afterwards, but

Re: [GENERAL] auto-increment in a view

2009-09-03 Thread Raymond O'Donnell
On 03/09/2009 17:22, Willy-Bas Loos wrote: > Hi, > > I'm trying to figure out to generate a auto-increment column in a view. > There is no physical column to base it on, the view contains a group > by clause, which renders that impossible. > In a normal query i can create a sequence for that purpo

[GENERAL] auto-increment in a view

2009-09-03 Thread Willy-Bas Loos
Hi, I'm trying to figure out to generate a auto-increment column in a view. There is no physical column to base it on, the view contains a group by clause, which renders that impossible. In a normal query i can create a sequence for that purpouse and drop it afterwards, but apart form it being ugl

Re: [GENERAL] auto increment within a compound key

2006-01-19 Thread Michael Fuhr
On Tue, Jan 17, 2006 at 04:33:46PM +0100, Bogdoll, Dieter wrote: > Is there any way to achieve the same result in Postgresql as the MySQL > AUTO_INCREMENT does? Not without an adverse impact on performance. PostgreSQL's serial type is just a notational convenience for an integer column that takes

[GENERAL] auto increment within a compound key

2006-01-19 Thread Bogdoll, Dieter
Title: auto increment within a compound key Hi, I want to create a compound primary key. The elements of this primary key should be the fields called nb (int) and d (double). nb should be default and autoincremented, so that the following four inserts insert into mytable (ts) values ( 1

Re: [GENERAL] Auto increment/sequence on multiple columns?

2004-09-15 Thread Thomas F . O'Connell
You'll probably need a sequence per thread. A sequence is not necessarily tied to a column. -tfo On Sep 12, 2004, at 11:16 AM, Nick wrote: This is actually a table that holds message threads for message boards. Column A is really 'message_board_id' and column B is 'thread_id'. I would like every

Re: [GENERAL] Auto increment/sequence on multiple columns?

2004-09-15 Thread Bruno Wolff III
On Sun, Sep 12, 2004 at 09:16:37 -0700, Nick <[EMAIL PROTECTED]> wrote: > This is actually a table that holds message threads for message > boards. Column A is really 'message_board_id' and column B is > 'thread_id'. I would like every new thread for a message board to have > a 'thread_id' of 1 a

Re: [GENERAL] Auto increment/sequence on multiple columns?

2004-09-11 Thread Thomas F . O'Connell
How does this imply one sequence? Is it guaranteed that for each value of a, the values of b will be equivalent to all (and only) values of a? There's plenty of flexibility within postgres for ways to use sequences. Regardless, I think you need to have (and present) a better idea of what you're

[GENERAL] Auto increment/sequence on multiple columns?

2004-09-10 Thread Nick
Is it possible to have a sequence across two columns. For example table1 +---+---+ | a | b | +---+---+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 1 | | 2 | 2 | | 2 | 3 | | 3 | 1 | | 3 | 2 | | 3 | 3 | +---+---+ Would I have to create a new sequence for every unique 'a' column? That seems pretty tedious.

[GENERAL] Auto increment?

2001-04-23 Thread K Old
Hello all, Any ideas how I can duplicate the auto increment feature that MySQL uses in PostgreSQL? (Other than doing a query to find the next number in que) Just thought I'd ask. Thanks, Kevin _ Get your FREE download of MSN Expl

List metadata tags (was Re: [GENERAL] Auto Increment)

2000-12-27 Thread Peter Eisentraut
Tom Lane writes: > At one time Marc was arranging for the list bot to append automatic > tags to all postings. I'd be in favor of an automatic tag that read > something like > > list administrivia: [EMAIL PROTECTED] > Postgres FAQs: http://... > > Suggestions anyone?

Re: [GENERAL] Auto Increment

2000-12-26 Thread Brett W. McCoy
On Wed, 27 Dec 2000, Tom Lane wrote: > At one time Marc was arranging for the list bot to append automatic > tags to all postings. I'd be in favor of an automatic tag that read > something like > > list administrivia: [EMAIL PROTECTED] > Postgres FAQs: http://... > >

Re: [GENERAL] Auto Increment

2000-12-26 Thread Tom Lane
>> Would posting a FAQ list on a regular basis to the list be >> helpful for things like this, like is done on the Perl newsgroups?] > I don't think so. Doesn't everyone know the location of the FAQ? Undoubtedly not :-( ... but it's unlikely that a routine posting would help to dispel cluelessn

Re: [GENERAL] Auto Increment

2000-12-26 Thread Bruce Momjian
> On Tue, 26 Dec 2000, Bruce Momjian wrote: > > > > See the documentation on CREATE SEQUENCE, and also on CREATE TABLE and the > > > SERIAL type. > > > > > > [An aside: this is something definitely that qualifies as a frequently > > > asked question, as this is like the 4th time in a week this q

Re: [GENERAL] Auto Increment

2000-12-26 Thread Brett W. McCoy
On Tue, 26 Dec 2000, Bruce Momjian wrote: > > See the documentation on CREATE SEQUENCE, and also on CREATE TABLE and the > > SERIAL type. > > > > [An aside: this is something definitely that qualifies as a frequently > > asked question, as this is like the 4th time in a week this question has >

Re: [GENERAL] Auto Increment

2000-12-26 Thread Bruce Momjian
> On Tue, 26 Dec 2000 [EMAIL PROTECTED] wrote: > > > Is there a way set a primary key to Auto Increment like you can > > with MySQL? > > See the documentation on CREATE SEQUENCE, and also on CREATE TABLE and the > SERIAL type. > > [An aside: this is something definitely that qualifies as a

Re: [GENERAL] auto increment

2000-11-09 Thread Martin A. Marques
On Jue 09 Nov 2000 07:56, Marcos wrote: > hi, > > i am creating a table and i want to add an auto incrementable field > > is that correct? > > psql ival << EOF > create table partes ( > codigo int not null auto_increment, WRONG. That is not ANSI-SQL. That is MySQL. Define it as SERIAL, ju

Re: [GENERAL] auto increment

2000-11-09 Thread Oliver Elphick
Marcos wrote: >hi, > >i am creating a table and i want to add an auto incrementable field > >is that correct? > >psql ival << EOF >create table partes ( >codigo int not null auto_increment, ^^ should be SERIAL -- Oliver Elphick

[GENERAL] auto increment

2000-11-09 Thread Marcos
hi, i am creating a table and i want to add an auto incrementable field is that correct? psql ival << EOF create table partes ( codigo int not null auto_increment, usuario varchar(15), fecha date, proyecto varchar(30), horas int4, trabajo varchar(100), observaciones varchar(90), primary

[GENERAL] Auto-increment datatypes and JDBC

2000-08-07 Thread Simon Brooke
The following message is a courtesy copy of an article that has been posted to comp.lang.java.databases as well. I have a Java database toolkit which I'm trying to make as portable as possible. It has to work with databases with minimal features as well as with databases with more features. The

Re: [GENERAL] Auto-increment Numeric Primary keys

2000-06-18 Thread Brett W. McCoy
On Sun, 18 Jun 2000, Vipin Samtani wrote: > How can I auto-increment numeric primary keys? So on a table called > "Test1" with fields "ID" and "Name" when I do an INSERT, I only type > > INSERT INTO Test1 values ('Bob'); > > instead of > > INSERT INTO Test1 values (1, 'Bob'); > > Is this impl

Re: [GENERAL] Auto-increment Numeric Primary keys

2000-06-18 Thread Mike Mascari
Vipin Samtani wrote: > > How can I auto-increment numeric primary keys? So on a table called > "Test1" with fields "ID" and "Name" when I do an INSERT, I only type > > INSERT INTO Test1 values ('Bob'); > > instead of > > INSERT INTO Test1 values (1, 'Bob'); > > Is this implemented in PostgreS

[GENERAL] Auto-increment Numeric Primary keys

2000-06-18 Thread Vipin Samtani
How can I auto-increment numeric primary keys? So on a table called "Test1" with fields "ID" and "Name" when I do an INSERT, I only type INSERT INTO Test1 values ('Bob'); instead of INSERT INTO Test1 values (1, 'Bob'); Is this implemented in PostgreSQL 7? -Vipin

Re: [GENERAL] auto increment

2000-03-23 Thread Bruce Momjian
> i believe you're interested in creating a sequence. bruce momjian's book, > in .pdf, covers this in section 7.4. the book can be found @ > www.postgresql.org/docs/awbook.html > i've found it a great reference for those topics covered. > I am working hard to finish it in the next month. -- B

Re: [GENERAL] auto increment

2000-03-23 Thread james
i believe you're interested in creating a sequence. bruce momjian's book, in .pdf, covers this in section 7.4. the book can be found @ www.postgresql.org/docs/awbook.html i've found it a great reference for those topics covered. cheers, james On Thu, 23 Mar 2000, [EMAIL PROTECTED] wrote: > How

Re: [GENERAL] auto increment?

1999-01-23 Thread David Hartwig
foo (ai, bar) VALUES ({nextvalresult}, 99); - Original Message - From: Robert Williams <[EMAIL PROTECTED]> To: Postgres <[EMAIL PROTECTED]> Sent: Saturday, January 23, 1999 7:28 PM Subject: Re: [GENERAL] auto increment? >That does the job. Thank you. > >Another re

Re: [GENERAL] auto increment?

1999-01-23 Thread Robert Williams
he user code to > explicitly assign its values. > > See CREATE_SEQUENCE in the doc. > > - Original Message - > From: Robert Williams <[EMAIL PROTECTED]> > To: Postgres <[EMAIL PROTECTED]> > Sent: Saturday, January 23, 1999 4:11 PM > Subject: [GENERAL]

Re: [GENERAL] auto increment?

1999-01-23 Thread David Hartwig
al Message - From: Robert Williams <[EMAIL PROTECTED]> To: Postgres <[EMAIL PROTECTED]> Sent: Saturday, January 23, 1999 4:11 PM Subject: [GENERAL] auto increment? >How do I set up a column as auto increment? I have looked >everywhere for the postgres equivalent ROWID as in Or

[GENERAL] auto increment?

1999-01-23 Thread Robert Williams
How do I set up a column as auto increment? I have looked everywhere for the postgres equivalent ROWID as in Oracle. -- Robert Williams [EMAIL PROTECTED] Jarob Consulting [EMAIL PROTECTED] Provo, Utah [EMAIL PROTECTED] begin:vcard n:Williams;Robert x-mozilla-html: