Andrus wrote:
> Commands:
>
> create temp table test ( id int, baas char(10) );
> create temp table lisa ( id int, baas char(10) );
> alter table lisa drop column id;
> INSERT INTO test SELECT * FROM lisa;
> drop table lisa;
>
> Cause error
>
> ERROR: column "id" is of type integer but expressi
Andrus wrote:
>> There isn't one. That's not how SQL works. You need to know what columns
>> your tables have.
>>
>> If you want to update the primary key just do something like:
>>
>> INSERT INTO t1 SELECT * FROM t2;
>> UPDATE t1 SET id = DEFAULT;
>>
>> Although if you don't know what your columns
Ray,
I don't think you can - here's what the docs[1] for INSERT say:
The target column names can be listed in any order. If no list of column
names is given at all, the default is all the columns of the table in
their declared order; or the first N column names, if there are only N
columns sup
There isn't one. That's not how SQL works. You need to know what columns
your tables have.
If you want to update the primary key just do something like:
INSERT INTO t1 SELECT * FROM t2;
UPDATE t1 SET id = DEFAULT;
Although if you don't know what your columns are called I can't see how
you can f
On 08/01/2009 20:10, Andrus wrote:
> Thank you.
>
>> Well, you've dropped the integer column from test, so now the INSERT
>> command is trying to stuff the char(10) value from test into the integer
>> column in lisa - which is what the error message is telling you.
>
> INSERT INTO test SELECT * F
Andrus wrote:
> Richard,
>
>> Don't use SELECT * - list the columns you want to insert. I can't think
>> why you would do that (you'll end up with nulls in the id column) but it
>> will work.
>
> In real table id is defined as
>
> id serial primary key
>
> so I excpect that it will be populated
Richard,
Don't use SELECT * - list the columns you want to insert. I can't think
why you would do that (you'll end up with nulls in the id column) but it
will work.
In real table id is defined as
id serial primary key
so I excpect that it will be populated with correct values.
List of column
Thank you.
Well, you've dropped the integer column from test, so now the INSERT
command is trying to stuff the char(10) value from test into the integer
column in lisa - which is what the error message is telling you.
INSERT INTO test SELECT * FROM lisa;
I need that test table primary key col
"Raymond O'Donnell" writes:
> I've no idea, in any case, whether you can expect SELECTing two columns
> into a one-column table to work.
It won't, but the other error happens to be detected first.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-general@p
On 08/01/2009 19:04, Andrus wrote:
> create temp table test ( id int, baas char(10) );
> create temp table lisa ( id int, baas char(10) );
> alter table lisa drop column id;
> INSERT INTO test SELECT * FROM lisa;
> drop table lisa;
>
> Cause error
>
> ERROR: column "id" is of type integer but e
On Thursday 08 January 2009, "Andrus" wrote:
> Commands:
>
> create temp table test ( id int, baas char(10) );
> create temp table lisa ( id int, baas char(10) );
> alter table lisa drop column id;
> INSERT INTO test SELECT * FROM lisa;
> How to fix ?
INSERT INTO test (baas) SELECT baas FROM l
Commands:
create temp table test ( id int, baas char(10) );
create temp table lisa ( id int, baas char(10) );
alter table lisa drop column id;
INSERT INTO test SELECT * FROM lisa;
drop table lisa;
Cause error
ERROR: column "id" is of type integer but expression is of type character
HINT: You
12 matches
Mail list logo