Muhib Al Hasan
Muhib Al Hasan

Reputation: 302

psql CREATE TABLESPACE shows syntax error

I tried to create a tablespace in a directory to store my databases but it returns syntax error everytime.

I entered :

CREATE TABLESPACE "general"
LOCATION "/media/tahnoon/qwerty/Data/PSQL DATABASES";

And it returned :

ERROR:  syntax error at or near ""/media/tahnoon/qwerty/Data/PSQL DATABASES""
LINE 2: LOCATION "/media/tahnoon/qwerty/Data/PSQL DATABASES";

I tried chown-ing the directory by :

sudo chown postgres:tahnoon PSQL\ DATABASES/

But it still doesn't work. Can anyone help me with it?

Upvotes: 1

Views: 608

Answers (1)

Daniel Vérité
Daniel Vérité

Reputation: 61546

The argument after LOCATION must be enclosed inside single quotes, not double quotes.

See the synopsis and examples in the CREATE TABLESPACE documentation:

CREATE TABLESPACE tablespace_name
    [ OWNER { new_owner | CURRENT_USER | SESSION_USER } ]
    LOCATION 'directory'
    [ WITH ( tablespace_option = value [, ... ] ) ]

Upvotes: 2

Related Questions