DEFINITIONS
Definitions More Info.
Definition ID
871
Title
POSTGRESQL
Category
NOTES
Definition
Postgresql export result with copy statement including return/newline character
Definition Description
https://stackoverflow.com/questions/51890980/postgresql-export-result-with-copy-statement-including-return-newline-character?noredirect=1#comment90734586_51890980
Birnci Yontem
1- COPY(SELECT unnest(array['SELECT now();', format('REINDEX TABLE %I.%I;', schemaname, relname)]) FROM pg_stat_all_tables ORDER BY n_dead_tup DESC)TO 'E:\scripts\maintenance\reindex.sql';
ikinci Yontem: COPY den sonra parantez icindeki komut return karakterini aldgiladigi icin, sorgu sorunsuz calisacaktir.
2-
COPY( SELECT 'SELECT now();'
'REINDEX TABLE "' || schemaname || '"."' || relname || '";'
'SELECT now(); ' FROM pg_stat_all_tables ORDER BY n_dead_tup DESC)TO 'E:\scripts\maintenance\reindex.sql';
RecordBy
cunay
Record Date
17-08-2018 14:50:47
Düzenle
Kopyala
Sil