pg_restore db.bin > db.sql
sudo -u postgres -i
psql -U postgres -W -d "valuevest" -f vv.sql -h localhost
- In psql:
\copy tablename to 'filename' csv;
- https://stackoverflow.com/questions/33826566/postgresql-what-is-the-best-way-to-export-specific-column-from-specific-table-fr
- Move the file to /tmp. Run:
copy <table_name> FROM '/tmp/<filename>.csv' WITH (FORMAT csv);
$ pg_dump --column-inserts --data-only --table=<table> <database>
$ pg_dump -h localhost -p 5432 -U postgres -d mydb -t my_table > backup.sql
postgres=# SELECT * FROM information_schema.columns WHERE table_schema = 'your_schema' AND table_name = 'your_table'
postgres=# \d+ <table_name>
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1)
\x on
TableName.objects.filter(date__gte=datetime.now()-timedelta(days=14)).delete()
Reference: