asendjasni
asendjasni

Reputation: 1074

PostgreSQL datatype ROW?

When I attempt to create a table with this command:

CREATE TABLE Client(ncli char(10) not null primary key,
                    nom char(32) not null,
                    adress row(rue char(30),
                    localite char(60)),
                    cat char(2));

I get an error saying :

ERROR: syntax error at or near "row"

Why do I get the error, and how can I avoid it?

Upvotes: 0

Views: 519

Answers (1)

Daniel E.
Daniel E.

Reputation: 2480

You can use row when you insert some values but I think when you create the table, you need to create a new type :

 CREATE TYPE myAdress AS (
       rue char(30),
       localite char(60)
    );

Then use it to create your table :

CREATE TABLE Client(ncli char(10) not null primary key,
                    nom char(32) not null,
                    adress myAdress,
                    cat char(2));

Here is the doc, if you want to learn more : http://www.postgresql.org/docs/9.3/static/rowtypes.html

Upvotes: 1

Related Questions