0

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?

2
  • 2
    I am not aware of that syntax in Postgres. You should probably just create a separate adresses table. Commented Apr 14, 2016 at 10:51
  • Where in the documentation of the create table statement did you find that syntax? Commented Apr 14, 2016 at 12:53

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you i will try it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.