2012/5/14 Tom Lane
> Carlos Mennens writes:
> > I'm not understanding why I'm not able to change this column type from
> > char to integer?
>
> > forza=# ALTER TABLE customers
> > ALTER COLUMN cust_id TYPE integer;
> > ERROR: column "cust_id" cannot be cast to type integer
>
> Try "ALTER ... cu
On Sun, May 13, 2012 at 8:11 PM, Tom Lane wrote:
> It strikes me that "cannot be cast" is a poor choice of words here,
> since the types *can* be cast if you try. Would it be better if the
> message said "cannot be cast implicitly to type foo"? We could also
> consider a HINT mentioning use of
Carlos Mennens writes:
> I'm not understanding why I'm not able to change this column type from
> char to integer?
> forza=# ALTER TABLE customers
> ALTER COLUMN cust_id TYPE integer;
> ERROR: column "cust_id" cannot be cast to type integer
Try "ALTER ... cust_id TYPE integer USING cust_id::int
On Fri, May 11, 2012 at 4:42 PM, Viktor Bojović
wrote:
> 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)
I'm not unde
On 2012-05-11, Carlos Mennens wrote:
> I have a problem in SQL I don't know how to solve and while I'm sure
> there are 100+ ways to do this in ANSI SQL, I'm trying to find the
> most cleanest / efficient way. I have a table called 'users' and the
> field 'users_id' is listed as the PRIMARY KEY. I
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 wrote:
> Thanks for all the
Carlos Mennens wrote on 11.05.2012 21:53:
Very good question and asked by myself to the original SQL author and
he explained while he didn't use the most efficient data types, he
used ones "he" felt would be more transparent across a multitude of
RDBMS vendors. So the answer is no, it would not
Carlos Mennens wrote on 11.05.2012 21:50:
On Fri, May 11, 2012 at 3:44 PM, Thomas Kellerer wrote:
Use this:
alter table users
alter column users_id type integer using to_number(users_id, '9');
(Adjust the '9' to the length of the char column)
When you wrote "Adjust the '9' t
On Fri, May 11, 2012 at 3:43 PM, Adrian Klaver wrote:
> 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.
On Fri, May 11, 2012 at 3:44 PM, Thomas Kellerer wrote:
> Use this:
>
> alter table users
> alter column users_id type integer using to_number(users_id, '9');
>
> (Adjust the '9' to the length of the char column)
When you wrote "Adjust the '9' to the length of the char column,
do y
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 ke
Carlos Mennens wrote on 11.05.2012 21:30:
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 fi
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 wh
Carlos Mennens wrote on 11.05.2012 21:03:
I have a problem in SQL I don't know how to solve and while I'm sure
there are 100+ ways to do this in ANSI SQL, I'm trying to find the
most cleanest / efficient way. I have a table called 'users' and the
field 'users_id' is listed as the PRIMARY KEY. I k
> -Original Message-
> From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-
> ow...@postgresql.org] On Behalf Of Carlos Mennens
> Sent: Friday, May 11, 2012 3:04 PM
> To: PostgreSQL (SQL)
> Subject: [SQL] Finding Max Value in a Row
>
> I have a problem in SQL I
On Fri, May 11, 2012 at 1:03 PM, Carlos Mennens
wrote:
> I have a problem in SQL I don't know how to solve and while I'm sure
> there are 100+ ways to do this in ANSI SQL, I'm trying to find the
> most cleanest / efficient way. I have a table called 'users' and the
> field 'users_id' is listed as
On Fri, May 11, 2012 at 9:03 PM, Carlos Mennens wrote:
> I have a problem in SQL I don't know how to solve and while I'm sure
> there are 100+ ways to do this in ANSI SQL, I'm trying to find the
> most cleanest / efficient way. I have a table called 'users' and the
> field 'users_id' is listed as
I have a problem in SQL I don't know how to solve and while I'm sure
there are 100+ ways to do this in ANSI SQL, I'm trying to find the
most cleanest / efficient way. I have a table called 'users' and the
field 'users_id' is listed as the PRIMARY KEY. I know I can use the
COUNT function, then I kno
18 matches
Mail list logo