Re: creating "user" table - Mailing list pgsql-general

From Chris
Subject Re: creating "user" table
Date
Msg-id 5.1.0.14.0.20010924075420.02cd2790@cooee.cybersydney.com.au
Whole thread Raw
In response to Re: creating "user" table  (Daniel ?erud <zilch@home.se>)
List pgsql-general
Hey,

> > Chris> Hi,
> > Chris> This one is more for the developers, but other
>comments welcome.
> >
> > Chris> Since we can't create a table called user in a
>normal database due to
> > Chris> the reserved keyword problem,
> >
> > False precondition!
> >
> >     template1=# create database demo;
> >     CREATE DATABASE
> >     template1=# \c demo
> >     You are now connected to database demo.
> >     demo=# create table "user" (name text, age int);
> >     CREATE
> >     demo=# \d
> >        List of relations
> >      Name | Type  | Owner
> >     ------+-------+--------
> >      user | table | merlyn
> >     (1 row)
> >
> >     demo=# \d user
> >               Table "user"
> >      Attribute |  Type   | Modifier
> >     -----------+---------+----------
> >      name      | text    |
> >      age       | integer |
> >
> >     demo=# insert into "user" values ('Randal', 39);
> >     INSERT 1034607 1
> >     demo=# insert into "user" values ('Russ', 38);
> >     INSERT 1034608 1
> >     demo=# insert into "user" values ('Ron', 35);
> >     INSERT 1034609 1
> >     demo=# select * from "user" order by age;
> >       name  | age
> >     --------+-----
> >      Ron    |  35
> >      Russ   |  38
> >      Randal |  39
> >     (3 rows)
> >
> >     demo=#
> >
> > You can quote any reserved word to get any name you want.
> > You just need to think of the table name of demo as
>_ "demo" _.
> >

True, didn't give that example, but.. try that in another DBMS :) I know
(at least) MySQL won't let you do that (*waits for the obvious comment*),
don't know about other DBMS needing quotes around the name, but I don't
think that one is portable to other systems :/

As Jochem pointed out in another post, by definition it's a reserved word
(both sql92 & 99) so I'll go back to my corner again :)


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


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Where are Perl DBI and DBD for PostgreSQL??
Next
From: missive@frontiernet.net (Lee Harr)
Date:
Subject: Re: My brain hurts - update field based on value of another table's field