Change owner of all the tables and sequences

for schema in 'public' 'firstschema' 'secondschema'
do
    for tbl in `psql -h hostname -U postgres -qAt -c "select tablename from pg_tables where schemaname = '$schema';" bddname`
    do
        psql -h hostname -U postgres -c "alter table ${schema}.$tbl owner to username" bddname
    done
done
for schema in 'public' 'firstschema' 'secondschema'
do
    for ...
more ...