Parse error creating tables

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

Parse error creating tables

От:
Juan Jose Natera Abreu <jnatera@net-uno.net>
Дата:
Hello all,

I Just installed PostGreSQL 7.1.2, and i created a database, but i am 
not able to create the tables i need to,

Here are 2 of the tables i am trying to create:

CREATE TABLE Distribucion ( 
        Id serial PRIMARY KEY NOT NULL,
        Nombre varchar(15)
);

CREATE TABLE Perfil_Aplicacion (
        Id serial PRIMARY KEY NOT NULL,
        Nombre varchar(20),
        Abreviatura char(4),
        Descripcion varchar(50),
        Distribucion integer,
        Enviar_Correo boolean,
        Enviar_Page boolean,
        Enviar_Popup boolean,
        Numero_Aprobadores integer,
        Numero_Acciones integer,
        Cierre_Automatico boolean,
        Caduca integer,
        FOREIGN KEY Distribucion REFERENCES Distribucion(Id)
);

I always get parsing errors like:

psql:/home/juanjose/proyectos/TroubleTickets/TablasTT.sql:39: ERROR:  
parser: parse error at or near "distribucion"

Since i couldnt create them by hand, I tryed using pgaccess 0.98.7

but if i try to add a constraint i get the same error and the table is 
not created, what am i doing wrong?

Thanks

Juan Jose
-- 
fortune generated signature:
"I am not an Economist. I am an honest man!" -- Paul McCracken 

Re: Parse error creating tables

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Juan Jose Natera Abreu  writes:
>         FOREIGN KEY Distribucion REFERENCES Distribucion(Id)

> I always get parsing errors like:
> parser: parse error at or near "distribucion"

There are supposed to be parentheses around the column list:

        FOREIGN KEY (Distribucion) REFERENCES Distribucion(Id)

			regards, tom lane

Re: Parse error creating tables

От:
"Nikola Milutinovic" <Nikola.Milutinovic@ev.co.yu>
Дата:
> Here are 2 of the tables i am trying to create:
> 
> CREATE TABLE Distribucion ( 
>         Id serial PRIMARY KEY NOT NULL,
>         Nombre varchar(15)
> );
> 
> CREATE TABLE Perfil_Aplicacion (
>         Id serial PRIMARY KEY NOT NULL,
>         Nombre varchar(20),
>         Abreviatura char(4),
>         Descripcion varchar(50),
>         Distribucion integer,
>         Enviar_Correo boolean,
>         Enviar_Page boolean,
>         Enviar_Popup boolean,
>         Numero_Aprobadores integer,
>         Numero_Acciones integer,
>         Cierre_Automatico boolean,
>         Caduca integer,
>         FOREIGN KEY Distribucion REFERENCES Distribucion(Id)
> );
FOREIGN KEY  REFERENCES 

Where  is another table, your table is referncing.

Nix.
FAQ