If you plan to keep history for long periods (many months), I suggest having a look at partitioning options - may be one partition for each day or week and so on. It does depend on the access patterns of you history table also (do you run queries that access data across dates? Do you do a lot of aggregations etc). Have a look at materialized views for storing aggregates/summaries. http://www.postgresql.org/docs/9.3/static/ddl-partitioning.htmlhttp://www.postgresql.org/docs/9.3/static/sql-creatematerializedview.html
Internally, a view is just a table with a rule, so this makes sense.
See here: https://postgresql.org/docs/9.5/static/rules-views.html
Views in PostgreSQL are implemented using the rule system. In fact, there is essentially no difference between:
CREATE VIEW myview AS SELECT * FROM mytab;compared against the two commands:
CREATE TABLE myview (same column list as mytab); CREATE RULE "_RETURN" AS ON SELECT TO myview DO INSTEAD SELECT * FROM mytab;because this is exactly what the
command does internally. This has some side effects. One of them is that the information about a view in the PostgreSQL system catalogs is exactly the same as it is for a table. So for the parser, there is absolutely no difference between a table and a view. They are the same thing: relations.CREATE VIEW
You need to read the documentation for the version you are using.
Since v12, is mandatory to get output to go to stdout. Having that behavior be obtained just by omitting -d was considered to be confusing. But since you want the output to go to a file, just name that file:-f -
pg_restore -Fd mydirectory -t sometable -f table.sql
I've just tried this:
pg_dump -s -t test.* -d test
It nicely exported all table definitions, as expected. is the same as -s. --schema-only
You could mess with the catalog table and set pg_attribute to attislocal, but modifying the system catalogs is unsupported and dangerous.FALSE
In my opinion, that is not warranted for a mere esthetic improvement. The dump works just as fine as it is.
If the data is smallish, I would just do the pg_dump, restore it to a temporary just-for-this-purpose database server, rename the schema within that temporary server (), and dump it out of that temporary server to do the final restore.ALTER SCHEMA...RENAME...