SQL Syntax: char to varchar type conversion(s)

From: Rachel Kay Street <Rachel(dot)K(dot)Street(at)rl(dot)ac(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: SQL Syntax: char to varchar type conversion(s)
Date: 1998-05-18 14:50:11
Message-ID: 35604AA3.41C6@rl.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

Can anyone answer this SQL question?

I have a field of type char in one table and wish to insert this
into a second table (with other fields) but the new field is of
type varchar. How do I proceed? The following (test) fails in pgsql.

create table temp1 ( code char(2) );
insert into temp1 values ('AB');
select * from temp1;
create table temp2 ( code1 char(10), code2 varchar(10) );
insert into temp2 (code1,code2) select code,code from temp1;
select * from temp2;

Rachel Street

****************************************************************
* R K Street - RAL Database Systems - (01235) 821900 ext 5833 *
* Rutherford Appleton Laboratory, Chilton, DIDCOT, Oxon, UK *
* Email: R(dot)K(dot)Street(at)rl(dot)ac(dot)uk or street(at)wdcc1(dot)bnsc(dot)rl(dot)ac(dot)uk *
****************************************************************

Browse pgsql-sql by date

  From Date Subject
Next Message Magnus Hagander 1998-05-18 14:52:29 Finding 'holes'
Previous Message Marin D 1998-05-18 12:29:02 Re: [SQL] primary keys