PostgreSQL 8.4 – Error Granting Access to Sequence

permissionspostgresqlpostgresql-8.4sequence

I'm attempting to run this query

GRANT USAGE ON [db].users_uid_seq TO [user];

db and user are redacted (obviously).

I get this error:

ERROR:  syntax error at or near "GRANT"

I've tried a number of permutations of users, including / not including the db prefix, slightly different syntax, etc. per other stack exchange postings with no luck.

I'm using PG 8.4 with namecheap's shared hosting plan. It looks like this wouldn't be an issue with a newer version of pg but I don't have that option right now.

Any suggestions are much appreciated.

Best Answer

The syntax for GRANT in PostgreSQL 8.4 is

GRANT { { USAGE | SELECT | UPDATE }
    [,...] | ALL [ PRIVILEGES ] }
    ON SEQUENCE sequencename [, ...]
    TO { [ GROUP ] rolename | PUBLIC } [, ...] [ WITH GRANT OPTION ]

You can't just exclude SEQUENCE. If you could it'd be in [], without which it's not optional.

GRANT USAGE ON SEQUENCE users_uid_seq TO myUser;

As a side note, PostgreSQL 8.4 was EOL on July 2014