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 tbl in `psql -h hostname -U postgres -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = '$schema';" bddname`
    do
        psql -h hostname -U postgres -c "alter table ${schema}.$tbl owner to username" bddname
    done
done