#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/postgresql-tools-psql - start SQL interpreter # # Copyright (c) 2004 Frank Meyer # # Creation: 30.07.2004 fm # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- . /var/install/include/eislib clrhome mecho -info "Start SQL interpreter" echo echo { echo "SELECT d.datname AS \"Name\"," echo " u.usename AS \"Owner\"," echo " pg_catalog.pg_encoding_to_char(d.encoding) AS \"Encoding\"," echo " pg_catalog.obj_description(d.oid, 'pg_database') AS \"Description\"" echo "FROM pg_catalog.pg_database d" echo " LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid" echo "ORDER BY 1;" } | /usr/local/pgsql/bin/psql template1 postgres echo echo -e 'database: \c' read database if [ "$database" = "" ] then mecho -warn "command cancelled" anykey exit 0 fi echo "select usename from pg_user;" | /usr/local/pgsql/bin/psql template1 postgres echo echo -e 'Database user [postgres]: \c' read user if [ "$user" = "" ] then user=postgres fi /usr/local/pgsql/bin/psql -U "$user" "$database" anykey exit 0