I know that Postgres uses MVCC and stores older versions of rows on disk. I would like to access (read-only) some old, discarded versions of a concrete row. How can I do it?
In PostgreSQL 9.1 and later, the best solution for this is https://github.com/omniti-labs/pgtreats/tree/master/contrib/pg_dirtyread which is an extension that provides a functional interface in sql to access old, unvacuumed versions of rows. Other tools may exist for other dbs. This works well for a number of cases data recovery, just exploring the utility of mvcc, and the like. With some effort it might work on earlier versions.
Related
i have two database cvtl and cvtl_db , i need to write a single query to retrieve data from table A in cvtl and table B in cvtl_db.
Postgres is throwing error: cross database reference are not implemented
Basically you have two ways:
Older tools.
If you need to support older versions of PostgreSQL, use dblink or DBI-link. These two provide robust support for cross-db queries across a number of PostgreSQL versions. pl/proxy is another possibility.
Newer tools.
The newer approach is to use foreign data wrappers. This has more functionality (such as better transaction handling) and probably has more eyes in terms of support than dblink etc do today.
Recently I came across a (maybe known problem) when Postgre's versions differ in major number (always upgrade, no downgrade), for example with field types.
In my case, there was very little conflicting data so I changed it by hand, but wanted to know more, in case I come across this problem again with more data.
In this concrete case (but can be extended to other possible problems in the future), I created the backup using only data inserts, as I had already the table structure saved.
The problem came when upgrading from 8.x to 9.x with the money type, I got errors because the inserts had a value something like
INSERT INTO foo(...) VALUES (...,'EUR300',...);
So postgres was refusing to insert that in 9.1
My idea, and what I tried is to convert that field to DECIMAL and redoing the dump, that worked, but in a future, is there another mechanism, like using newer pg_dump connecting to old database, instead of current one? (Did not tested this)
When going etween different versions, you should always use the new version of pg_dump. Meaning when you go from 8.x to 9.1, you should use pg_dump version 9.1. It should normally take care of any conversions necessary.
I have a task at hand wherein we need to compare two database schemas at two different versions.
Actually an application has been upgraded to use Oracle 11g , older version of the application used Oracle 10g. Basically what needs to be checked is the differences in the schemas of the two different versioned applications mainly to check if no functionality is broken or no relevant schema change is missed
I did some R&D and found many tools are available to compare schemas, DB Solo etc. But my requirement being to compare two schemas at 2 different versions. The tools are available to compare schemas at same version.
Some of the solutions I came up with after having discussions with seniors
1) establish a DB link between the 2 DB schemas and do a comparison of USER_OBJECTS. This solution is however not feasible for us.
2) If we can get a TEXT like dump of both the schemas, a basic text comparison would give the schema differences.
However, I do not know how Solution 2 would be possible.
I have seen some older posts like
Compare two schemas and update the old schema with the new columns of new schema but I need a more simplistic solution!
Your help is appreciated.
Did you already try "Tools"->"Database Diff" from Oracle SQL Developer ?
I want to be able to track changes to records in a PostgreSQL database. I've considered using a version field and on-update rules or triggers such that previous versions of records are kept in the table (or in a separate table). This would have the advantage of making it possible to view the version history of a record with a simple select statement. However, this functionality is something I think likely to be seldom used.
How could I satisfy the requirement of being able to construct a "version history" for a record using the WAL files? Reading the WAL and Point-in-Time recovery documentation at PostgreSQL.org has helped me understand how the state of the entire database can be rolled back to an arbitrary point in time, but not how to deal with update mistakes in particular records.
No, you cannot do this at this time. There is a large effort underway on the postgresql-hackers mailing list (the dev list) to rework WAL and build an interface to allow for logical replication in (possibly) PostgreSQL 9.3.
This is basically what you appear to be trying to do and, based on the discussions on that list, it is definitely not a trivial task.
Does anyone know what substantial differences there are between the regular PostgreSQL and Postgres Plus?
The database is the same, meaning that the SQL is fully compatible to any other PostgreSQL installation around (save for the GIS data formats).
The main difference is that there is a bunch of modules and tools bundled with Postgres Plus that you would have to collect and install separately and by yourself otherwise. Thus the main advantage is easy and speedy installation.
Most of the bundled stuff looks like it's freely available from other sources. That Postgres Studio application looks suspiciously close to pgAdmin III.
One important difference is the licence:
Postgres Plus is only free for "non-production" use.
you can find detailed purchasing options here:
http://www.enterprisedb.com/products/purchase.do
Postgres PLUS is proprietary, PostgreSQL is Open source under permissive license (and that's why Postgres PLUS is proprietary).
Postgres PLUS has support for Oracle PL/SQL, while PostgreSQL does not, at least not officially.
Those are two most obvious differences.
I used 8.2 and when was the time to switch to 8.3 I tried PostGresPlus.
The Speed was a lot faster. LOT I mean queries that took 30 secs, takes now less than 2 seconds. I am not sure if it's 8.3 that is faster or the Enterprise Plus but I can tell you that I was impressed.
Other thing that I like is that I can debug proc stored. It cames with more tools.