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

Re: Finding Max Value in a Row

From: Viktor Bojović <viktor(dot)bojovic(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 20:42:38
Message-ID: CAJu1cLZkviTdxDhY1LynMbuqueCdcQUd5_1Yx+FLD+gVNHqtXA@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
you can convert from type to type using ::varchar or ::char(size) or
::integer
so you can use sequence but you will have to convert it's result to
suitable type (that can also be put in default value of user_id attribute)

On Fri, May 11, 2012 at 9:30 PM, Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>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 why...it 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 TABLE users
> 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?
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

In response to

Responses

pgsql-sql by date

Next:From: Jasen BettsDate: 2012-05-11 21:59:45
Subject: Re: Finding Max Value in a Row
Previous:From: Thomas KellererDate: 2012-05-11 20:05:24
Subject: Re: Finding Max Value in a Row

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