I have a ruby on rails application hosted on heroku using postgresql as its database. Since the database is getting pretty large, I was wondering if there's a way to download only a specific part of it off of heroku. For example, is it possible to download only one specific table, or download only rows with parent_id == x.
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- NOT DISTINCT query in mySQL
- Eager-loading association count with Arel (Rails 3
- Flush single app django 1.9
相关文章
- postgresql 关于使用between and 中是字符串的问题
- postgresql 月份差计算问题
- Using boolean expression in order by clause
- Right way to deploy Rails + Puma + Postgres app to
- Table valued Parameter Equivalent in Postgresql
- in redshift postgresql can I skip columns with the
- AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
Using the
DATABASE_URL
config setting you can usepg_dump
to access your database and use the-t
switch to specify a certain table.For example, to export the table
my_table
into file calleddb.sql
:If you need to limit the download to certain rows then I don't think
pg_dump
will do the job on it's own. You could create another table in your Heroku database to first define the subset of rows that you want to download and then havepg_dump
dump only that table. See this question for some ideas about how to do that: Export specific rows from a PostgreSQL table as INSERT SQL scriptIn addition to Steve's quite correct answer, you also have the option of connecting using
psql
to theDATABASE_URL
and using\copy
, e.g.You can extract whole tables, or the output of arbitrary queries (including joins etc). The table definition (DDL) is not exported this way, but can be dumped with
pg_dump --schema-only -t ...
.