Re: pg with different sql?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pocm(at)rnl(dot)ist(dot)utl(dot)pt (Paulo J(dot) Matos)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: pg with different sql?
Date: 2002-01-13 22:39:34
Message-ID: 28929.1010961574@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

pocm(at)rnl(dot)ist(dot)utl(dot)pt (Paulo J. Matos) writes:
> AFAIK, SQL is standard and should be the same for all DBMSs.

...rotfl...

The standard is what it is, but almost everybody has their own set of
extensions, variations, etc. You seem to have acquired a few
nonstandardisms from your previous exposure.

> CREATE TABLE socio (
> id integer SERIAL PRIMARY KEY,
> nome varchar,
> alcunha string,
> data_filiacao date)

integer OR serial, please, not both. (Serial isn't standard, btw.)

"string" is not a datatype known to Postgres. Try "text",
or if you want to actually conform to the standard, "varchar(N)".
(varchar with no length limit, as in your second field, isn't
standard either.)

Also, if you're entering these commands via psql, you need a semicolon
after each one.

> CREATE TABLE paga_cota (
> ano integer,
> mes integer,
> valor integer,
> id integer,
> PRIMARY KEY(id,ano,mes),
> FOREIGN KEY(id) REFERENCES(socio))

By my reading of the SQL spec the last line should be

FOREIGN KEY(id) REFERENCES socio)

There's nothing I can see in the SQL92 syntax that allows parentheses
around the name of the referenced table.

If this stuff works as-is on some other RDBMS, then you've learned
some nonstandard habits. We're not any better; we've got our own
set of nonstandardisms. Just not those ones.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message George Moga 2002-01-13 23:01:43 Re: pg with different sql?
Previous Message Jean-Luc Lachance 2002-01-13 22:38:34 Re: pg with different sql?