From: | "Alain TESIO" <tesio(at)easynet(dot)fr> |
---|---|
To: | <pgsql-general(at)postgreSQL(dot)org> |
Subject: | A script which drops a column |
Date: | 1999-11-26 02:50:47 |
Message-ID: | 00fc01bf37b9$10fa9bc0$d65f72c3@atesio |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
You may be interested by a script which drops a column as this
feature isn't supported by Postgresql. I guess it could be easier
and nice in Perl or something similar but I'm using what I know.
The parameters are in that order :
the name of the database
the table
the column to drop
Alain
#!/bin/sh
psql -d $1 -c "\d $2" | awk 'BEGIN { keep=1 } /+-/ { keep=1-keep } { if
(keep) { print } }' | grep -v "\-\-" | grep -v "Table *=" | grep -v " $3 " |
sed "s/| \([^ ]*\).*/\1/" | tr -s \\012 "," | sed "s/,$//" | sed
"s/\(.*\)/select \1 into temp tmp_drop_column from $2 ; drop table $2 ;
select * into $2 from tmp_drop_column;/" > tmp_sql_drop_column
psql -d $1 -f tmp_sql_drop_column
rm tmp_sql_drop_column
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Mascari | 1999-11-26 04:26:02 | Re: [HACKERS] Re: [GENERAL] drop/rename table and transactions |
Previous Message | Lincoln Yeoh | 1999-11-26 01:08:04 | Re: [GENERAL] drop/rename table and transactions |