regex - Regular expression for removing Postgres SQL data insert (COPY) statements. -


my postgres dump (pg_dump > file.sql) contains data want remove. there simple regex (or sed/awk command) delete lines between particular copy table_name statement , termination word ("."). know regex's aren't ideal not matches , multi-line patterns, tried these anyway (in sublime find/replace):

"copy ((?!\\[.])*.*)*"  "copy ((?!\\[.]$)*(.[\n])*)*"  "copy (?!\\[.]$)(.*[\n]*)*" 

the closest can match first line of data after copy statement:

"copy (?!\\[.]$).*[\n]+.*[\n]+" 

in general, want follows (note poses issues foreign key dependencies in cases:

pg_dump -s mydatabase > dump.sql pg_dump -a -t table_i_want1 -t table_i_want2 -t table_i_want3 >> dump.sql 

the -s flag means --schema-only , -a flag tells "append" (i.e. data only).


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -