-
-
Save matlads/5625931 to your computer and use it in GitHub Desktop.
Check for proper number of command line args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/sh | |
| if [ $# -ne 5 ] | |
| then | |
| echo "Usage: "$0" DBUSER DB TABLE COL NEWSIZE" | |
| else | |
| USER=$1 | |
| DB=$2 | |
| TABLE=$3 | |
| COL=$4 | |
| SIZE=$5 | |
| echo "Resizing COL ["$COL"] in TABLE ["$DB"."$TABLE"] to "$SIZE | |
| psql $DB -U $USER <<SQL | |
| SELECT atttypmod as "CURRENT_SIZE" FROM pg_attribute WHERE attrelid = '$TABLE'::regclass AND attname = '$COL'; | |
| UPDATE pg_attribute SET atttypmod = $SIZE+4 WHERE attrelid = '$TABLE'::regclass AND attname = '$COL'; | |
| SELECT atttypmod as "NEWSIZE" FROM pg_attribute WHERE attrelid = '$TABLE'::regclass AND attname = '$COL'; | |
| SQL | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sure. Makes us assume less...