Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql db owner change


        
            
        
     ALTER DATABASE target_database OWNER TO new_onwer;
Comment

how to change owner in postgres

ALTER DATABASE name OWNER TO new_owner;
Comment

postgres alter table owner

ALTER TABLE <tablename> OWNER TO <username>
Comment

postgres alter owner of all tables


#TABLES
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" YOUR_DB` ; do  psql -c "alter table "$tbl" owner to NEW_OWNER" YOUR_DB ; done

#SEQUENCES
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB` ; do  psql -c "alter sequence "$tbl" owner to NEW_OWNER" YOUR_DB ; done

#VIEWS
for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" YOUR_DB` ; do  psql -c "alter view "$tbl" owner to NEW_OWNER" YOUR_DB ; done
Comment

postgresql set owner of table

ALTER TABLE "schemaname"."tablename" OWNER TO role_name;
Comment

Alter owner in PostgreSQL

pg_dump -Fp -f dbbackup.dmp <dbname>
vi dbbackup.dmp
:%s/oldowner/newowner/g
save and exit
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql workbench requires visual c++ 2019 redistributable package 
Sql :: ubuntu mysql cannot connect to database server remote 
Sql :: insert query in ci 
Sql :: remove binlog mysql 
Sql :: create table sqlite 
Sql :: mysql delete user if exists 
Sql :: mysql sort descending 
Sql :: mysql grant grant option 
Sql :: what is my mysql version 
Sql :: postgresql search object in array 
Sql :: sql truncate statement 
Sql :: how to create enum in postgresql 
Sql :: how to get id of last inserted row in mysql 
Sql :: sql order by where condition 
Sql :: get value from a table an insert it with other values in another table sql 
Sql :: mysql show table structure 
Sql :: calculate distance between two latitude longitude points sql 
Sql :: start mysql 
Sql :: count columns psql(PostreSQL) 
Sql :: convert sql to relational algebra 
Sql :: print year of a date sql 
Sql :: postgres json to string 
Sql :: sql_calc_found_rows 
Sql :: how to login sql server using cmd 
Sql :: delete join select from one table based on multiple values 
Sql :: avg mysql 
Sql :: oracle sql pad left zeros 
Sql :: sql create view 
Sql :: mysql select into new table 
Sql :: foreign key constraint in ms sql 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =