Re: failed SQL CREATE TABLE

From: Chris <csmith(at)squiz(dot)net>
To: Tim Wilson <wilson(at)isis(dot)visi(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: failed SQL CREATE TABLE
Date: 2002-04-09 04:07:42
Message-ID: 5.1.0.14.0.20020409140551.045d0ec0@cooee.cybersydney.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Tim,

The initial thing that springs to mind is that 'end' is a reserved keyword
(for use with transactions), so if you want to use it in a table you have
to quote it ("end").

Either that, or, rename the field to for example end_time.

>I'm trying to create a database and I'm getting some errors when I try
>to create some of the tables. I'm going to post the SQL and the errors
>and I'd appreciate it if there's a guru on the list who'd have a look
>and let me know where I'm messing up. Everything looks OK to me, but
>doesn't it always in situations like this. :-)
>
>Here's the SQL:

<snip>

>CREATE TABLE event (
> event_id SERIAL PRIMARY KEY,
> event_name VARCHAR(30),
> location_id INTEGER,
> start TIMESTAMP,
> end TIMESTAMP,
> description TEXT,
> username CHAR(10),
> CONSTRAINT location_exists FOREIGN KEY (location_id)
> REFERENCES location
> ON UPDATE CASCADE
> ON DELETE SET NULL,
> CONSTRAINT username_exists FOREIGN KEY (username)
> REFERENCES submitter
> ON UPDATE CASCADE
> ON DELETE SET NULL
>);

<snip>

>psql:/home/wilson/make_eventdb.sql:37: ERROR: parser: parse error at or
>near "end"

-----------------
Chris Smith
http://www.squiz.net/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-04-09 04:18:02 Re: failed SQL CREATE TABLE
Previous Message Tim Wilson 2002-04-09 03:50:18 failed SQL CREATE TABLE