Search
 
SCRIPT & CODE EXAMPLE
 

SQL

ERROR: permission denied for table accounts postgresql 13

su - postgres <<xEOFx
set +H

psql -c "CREATE DATABASE mydb"
psql -c "CREATE USER user01 WITH ENCRYPTED PASSWORD 'SomePassword'"

psql -c "GRANT ALL PRIVILEGES ON ALL TABLES    IN SCHEMA public to user01"
psql -c "GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to user01"
psql -c "GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to user01"

psql --dbname=mydb --username=postgres -f /tmp/mydb.sql
psql -c "GRANT ALL PRIVILEGES ON DATABASE mydb TO user01"

psql -c "ALTER USER postgres WITH PASSWORD 'AnotherPassword'"
exit
xEOFx
Comment

ERROR: permission denied for table accounts postgresql 13

CREATE OR REPLACE FUNCTION auto_grant_func()
RETURNS event_trigger AS $$
BEGIN
    grant all on all tables in schema public to <username>;
    grant all on all sequences in schema public to <username>;
    grant select on all tables in schema public to <username>;
    grant select on all sequences in schema public to <username>;
END;
$$ LANGUAGE plpgsql;

CREATE EVENT TRIGGER auto_grant_trigger
    ON ddl_command_end
    WHEN TAG IN ('CREATE TABLE', 'CREATE TABLE AS')
EXECUTE PROCEDURE auto_grant_func();
Comment

PREVIOUS NEXT
Code Example
Sql :: drop database mysql 
Sql :: sql select data type of query 
Sql :: postgres stored procedure 
Sql :: mysql sql.gz 
Sql :: create-table 
Sql :: SQL INNER JOIN With Three Tables 
Sql :: mysql query where in select 
Sql :: spark apache sql coalesce 
Sql :: back up stored procedures mysql 
Sql :: sql use with to get value counts and percentages 
Sql :: sql get actual fiscal year 
Sql :: alter session set nls_language french 
Sql :: what is truncate in sql 
Sql :: oracle boolean to varchar 
Sql :: mysqli_free_result 
Sql :: sql order 
Sql :: npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sqlite3@4.2.0 install: `node-pre-gyp install --fallback-to-build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the sqlite3@4.2.0 install script. 
Sql :: sql not in operator 
Sql :: rename temp table column name in sql server 
Sql :: oracle synonym procedure 
Sql :: duplicate key value violates unique constraint "django_admin_log_pkey" 
Sql :: h2 auto increment and unique 
Sql :: merge command in sql 
Sql :: install pymysql in python 3 in windows 7 v2.7.10 codes with pip 
Sql :: long string type sql 
Sql :: mysql select non integer values 
Sql :: how to install mysql workbench in ubuntu 20.04 
Sql :: alter rename command in mysql 
Sql :: incorrect datetime value sql table error 1292 
Sql :: character count sql 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =