GRANT USAGE, SELECT, UPDATE ON ALL sequences IN events TO sdacadbhmz01
Assistant
The SQL command you provided is intended to grant privileges on all sequences in the events schema to the user sdacadbhmz01. Here's a quick breakdown and confirmation:
sql
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01;
Explanation:
GRANT: Command to give privileges.
USAGE: Allows the user to use the sequence (e.g., to call nextval()).
SELECT: Allows reading the current value of the sequence.
UPDATE: Allows setting the sequence value (e.g., via setval()).
ON ALL SEQUENCES IN SCHEMA events: Applies these privileges to all sequences inside the events schema.
TO sdacadbhmz01: Grants these privileges to the role/user named .
User
GRANT USAGE, SELECT, UPDATE ON ALL sequences IN schema events TO sdacadbhmz01
Is this correct?
Still having issue
Assistant
Your command syntax is almost correct except for case sensitivity and SQL keyword capitalization which generally does not matter, but sometimes copy-pasting or subtle errors cause issues.
The exact correct syntax in PostgreSQL is:
sql
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01;
Let's carefully verify common potential issues:
1. Use SEQUENCES in uppercase (not sequences)
While PostgreSQL is case-insensitive for keywords, best practice is to use uppercase for keywords:
User
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA ethwindexer TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA ethindexer_holesky TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA xrpindexer TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA substrateindexer TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA oauth TO sdacadbhmz01
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA node_cfg TO sdacadbhmz01;
/* ERROR: syntax error at or near "GRANT"
LINE 2: GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA ethwi...
^ /
/ Affected rows: 0 Found rows: 0 Warnings: 0 Duration for 0 of 1 query: 0.000 sec. */
Assistant
The error message you're seeing (syntax error at or near "GRANT" at LINE 2) indicates that you are likely running all those GRANT statements together as a single query without separating them properly.
Important:
Each GRANT statement must be executed separately or separated by semicolons (;).
Without semicolons, the SQL parser thinks the entire block is one statement, resulting in a syntax error at the second GRANT.
How to fix:
Add a semicolon ; at the end of each GRANT statement, like this:
sql
sdacadbhmz01
Notes:
The original statement you wrote is almost correct, but the keyword SCHEMA is missing. In PostgreSQL, to grant privileges on all sequences in a schema you need to specify IN SCHEMA.
Make sure sdacadbhmz01 is a valid user/role in your database.
This will not apply to sequences created after this command is run. To automatically grant privileges on sequences created later, you might want to adjust the default privileges:
sql
ALTER DEFAULT PRIVILEGES IN SCHEMA events
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO sdacadbhmz01;
If you want, I can help with that as well!
sql
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01;
2. Check that the schema name events exists and is spelled correctly.
3. Check that the user sdacadbhmz01 exists.
4. Confirm the user running the GRANT has the necessary privileges to grant these permissions.
5. If sequences were created after this grant, the grant will not apply automatically. To cover future sequences, you must run:
sql
ALTER DEFAULT PRIVILEGES IN SCHEMA events
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO sdacadbhmz01;
Additional debug steps:
You can verify the privileges granted on sequences by querying the catalog:
sql
SELECT sequence_schema, sequence_name, privilege_type, grantee
FROM information_schema.role_routine_grants
WHERE sequence_schema = 'events' AND grantee = 'sdacadbhmz01';
Or check with:
sql
\dp events.*
in psql to see privileges on sequences/tables.
Summary: Correct command to grant privileges on all sequences in events schema:
sql
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01;
If it still does not work, please share the exact error message you are seeing. That will help diagnose further.
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA events TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA ethwindexer TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA ethindexer_holesky TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA xrpindexer TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA substrateindexer TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA oauth TO sdacadbhmz01;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA node_cfg TO sdacadbhmz01;
Additional tips:
If you are running these inside a SQL client or script, semicolons tell the system where one statement ends and the next begins.
When running queries manually in interactive tools like psql, just press enter after each statement or run them one by one.
Summary
Syntax error due to missing semicolons between statements.
Add semicolons (;) and run all commands again. That will fix your syntax error.