0

I use following command for grant postgres db. It is working.

for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" performanceeyedev` ; do  psql -c "alter table $tbl owner to prodteam" performanceeyedev ; done

I write following script for grant postgres db. But it isn't working.

DB = 'performanceeyedev';
OWNER = 'prodteam';

for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" $DB` ;
do  psql -c "alter table $tbl owner to $OWNER" $DB ; done

for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" $DB` ;
do  psql -c "alter seq $tbl owner to $OWNER" $DB ; done

It make following result

./grant.sh: line 1: DB: command not found
./grant.sh: line 2: OWNER: command not found
ERROR:  syntax error at end of input
LINE 1: alter table dir_destinations_dir_dest_id_seq owner to 
                                                              ^
ERROR:  syntax error at end of input
LINE 1: alter table dir_types_dir_type_id_seq owner to 
                                                       ^
ERROR:  syntax error at end of input
LINE 1: alter table dir_specialities_dir_sp_id_seq owner to 
                                                            ^
ERROR:  syntax error at end of input
LINE 1: alter table lb_report_types_id_seq owner to 
                                                    ^
ERROR:  syntax error at end of input
LINE 1: alter table too_many_submission_summary_id_seq owner to 
                                                                ^
ERROR:  syntax error at end of input
LINE 1: alter table web_campaigns_web_camp_id_seq owner to

Please help me.

2
  • Could you elaborate? What is not working? What is the expected result? What is the actual result? Error messages? Please edit your question accordingly. Commented Jun 21, 2012 at 6:06
  • stackoverflow.com/questions/2268104/… Commented Jun 21, 2012 at 13:12

1 Answer 1

4

do not leave space between variable and '=' when assign a variable

DB='performanceeyedev';
OWNER='prodteam';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.