Обсуждение: create table bug: the "no" string can't be a column

Поиск
Список
Период
Сортировка

create table bug: the "no" string can't be a column

От
mapaquin@cca.qc.ca (Marc Andre Paquin)
Дата:
Hello,

I am transfering data from a database Postgres 6.0 to a 6.4 version.

The pg_dump wont do the trick...

I had to create the database manually on 6.4. So I must replacate the exact
structure of the old  database. But I can't! One of my column name is "no" for
number in french... It seems that I get an error message with a create table
statment. I have tried to trick it: I named the column "no" to "noo" and tried to
alter table to change the name afterwards... no luck. But the "noo" is working fine!
Changing the "no" column is not an option... many programs depends on it!!!

What can I do? What would be the right syntax?

create table test (no char(8), city int4, region int4);
--
Marc André Paquin, adjoint au chef  T. I.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Centre Canadien d'Architecture  |   C C A
http://cca.qc.ca

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Re: [GENERAL] create table bug: the "no" string can't be a column

От
reedstrm@wallace.ece.rice.edu (Ross J. Reedstrom)
Дата:
Marc -
Try this out:

test=> create table test (no char(8), city int4, region int4);
ERROR:  parser: parse error at or near "no"
test=> create table test ("no" char(8), city int4, region int4);
CREATE
test=> \d test

Table    = test
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| no                               | char()                           |     8 |
| city                             | int4                             |     4 |
| region                           | int4                             |     4 |
+----------------------------------+----------------------------------+-------+
test=> select version();
version
-------------------------------------------------------------
PostgreSQL 6.4.2 on i686-pc-linux-gnu, compiled by gcc 2.7.2.
(1 row)

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
>
> I am transfering data from a database Postgres 6.0 to a 6.4 version.
>
> The pg_dump wont do the trick...
>
> I had to create the database manually on 6.4. So I must replacate the exact
> structure of the old  database. But I can't! One of my column name is "no" for
> number in french... It seems that I get an error message with a create table
> statment. I have tried to trick it: I named the column "no" to "noo" and tried to
> alter table to change the name afterwards... no luck. But the "noo" is working fine!
> Changing the "no" column is not an option... many programs depends on it!!!
>
> What can I do? What would be the right syntax?
>
> create table test (no char(8), city int4, region int4);
> --

--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005

Re: [GENERAL] create table bug: the "no" string can't be a column

От
The Hermit Hacker
Дата:
On Wed, 2 Jun 1999, Marc Andre Paquin wrote:

> Hello,
>
> I am transfering data from a database Postgres 6.0 to a 6.4 version.
>
> The pg_dump wont do the trick...
>
> I had to create the database manually on 6.4. So I must replacate the exact
> structure of the old  database. But I can't! One of my column name is "no" for
> number in french... It seems that I get an error message with a create table
> statment. I have tried to trick it: I named the column "no" to "noo" and tried to
> alter table to change the name afterwards... no luck. But the "noo" is working fine!
> Changing the "no" column is not an option... many programs depends on it!!!
>
> What can I do? What would be the right syntax?
>
> create table test (no char(8), city int4, region int4);

Try it as:

create table test ("no" char(8), city int4, region int4);

scrappy=> insert into test (no,city,region) values ('1',2,3);
ERROR:  parser: parse error at or near "no"
scrappy=> insert into test ("no",city,region) values ('1',2,3);
INSERT 4293227 1

You always have to use the "'s around no though...

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org