altocompta/contrib/sql-utility/get-sql.sh
2006-05-01 18:11:55 +00:00

28 lines
410 B
Bash
Executable file

#!/bin/bash
#
#
# Author Dany De Bontridder
# Under the GPL 2 minimun
#
Help () {
cat <<_eof
$0 [option] database
-f function only
-t table only
_eof
}
if [ $# -lt 2 ]; then
Help
fi
case "$1" in
-f)
pg_dump -s "$2"|awk '/CREATE FUNCTION/,/LANGUAGE/ { print $0;}'
;;
-t)
pg_dump -s "$2"| awk '/CREATE TABLE/,/;/ { print $0;}'
pg_dump -s "$2"| awk '/ALTER TABLE/,/;/ { print $0;}'
;;
esac