Skip site navigation (1) Skip section navigation (2)

Re: Finding Max Value in a Row

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: "PostgreSQL (SQL)" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Finding Max Value in a Row
Date: 2012-05-11 19:43:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On 05/11/2012 12:30 PM, Carlos Mennens wrote:
> Thanks for all the help thus far everyone! I sadly didn't
> create/design the table and would love to create a SEQUENCE on that
> particular field but not sure how unless I DROP the table and create
> from scratch.
> Currently the data TYPE on the primary key field (users_id) is CHAR
> and I have no idea should be NUMERIC or SERIAL but it's not
> so my question is if I want to ALTER the column and create a sequence,
> would I simply do:
> ALTER COLUMN users_id TYPE serial
> ;
> Obviously if any of the data stored in users_id is actual CHAR, I'm
> guessing the database would reject that request to change type as the
> existing data would match. However the data type is CHAR but the field
> values are all numeric from 1000000010 - 1000000301 so I'm hoping that
> would work for SERIAL which is just INTEGER, right?

Well the question to ask is if it is declared CHAR was that done for a 
legitimate reason? One reason I can think of is to have leading 0s in a 
'number'. Might want to double check that code downstream is not 
depending on CHAR behavior.

Adrian Klaver

In response to


pgsql-sql by date

Next:From: Thomas KellererDate: 2012-05-11 19:44:03
Subject: Re: Finding Max Value in a Row
Previous:From: Adrian KlaverDate: 2012-05-11 19:39:18
Subject: Re: [SQL] pg_dump: aborting because of server version mismatch

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group