Thread: sequences in schemas

sequences in schemas

From
Joe Maldonado
Date:
Hello,
How come within a create schema block I cannot create a sequence?
I have entered in:

CREATE SCHEMA joe
    CREATE SEQUENCE joe_seq start 1
    CREATE TABLE joe_table (int id, varchar name)
;

and I get a syntax error for SEQUENCE. though if it is just tables I do not

-Joe

Re: sequences in schemas

From
Pierre-Frédéric Caillaud
Date:
    You forgot the ";"

  CREATE SCHEMA joe;
  CREATE SEQUENCE joe.joe_seq start 1;
  CREATE TABLE joe.joe_table (int id, varchar name);


Re: sequences in schemas

From
Manfred Koizar
Date:
On Tue, 31 Aug 2004 11:09:07 -0400, Joe Maldonado
<jmaldonado@webehosting.biz> wrote:
>CREATE SCHEMA joe
>    CREATE SEQUENCE joe_seq start 1
>    CREATE TABLE joe_table (int id, varchar name)
>;
>
>and I get a syntax error for SEQUENCE.

This will work in 8.0.

http://www.postgresql.org/docs/7.4/static/sql-createschema.html:
schema_element
    An SQL statement defining an object to be created within the schema.
Currently, only CREATE TABLE, CREATE VIEW, and GRANT are accepted as
clauses within CREATE SCHEMA.

http://developer.postgresql.org/docs/postgres/sql-createschema.html:
schema_element
    An SQL statement defining an object to be created within the schema.
Currently, only CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE
SEQUENCE, CREATE TRIGGER and GRANT are accepted as clauses within CREATE
SCHEMA.

In the meantime "Other kinds of objects may be created in separate
commands after the schema is created."

Servus
 Manfred