eyeballpaul
eyeballpaul

Reputation: 1735

Postgres equivalent to Sql Servers @@DBTS

I am mainly from a Sql Server background, and following some issues with getting MySql to work with the Microsoft Sync Framework (namely it does not cater for snapshots), I am having to look into Postgres and try to get that working with the Sync Framework.

The triggers that are needed include a call to function "@@DBTS", but I am having trouble finding an equivalent in Postgres for this.

From the microsoft documentation for this it says:

@@DBTS returns the current database's last-used timestamp value. 
A new timestamp value is generated when a row with a timestamp 
column is inserted or updated.

In MySql it was the following:

USE INFORMATION_SCHEMA;
SELECT MAX(UPDATE_TIME) FROM TABLES WHERE UPDATE_TIME < NOW();

Can anyone tell me what this would be in Postgres?

Upvotes: 1

Views: 509

Answers (1)

user330315
user330315

Reputation:

PostgreSQL does not keep track when a table was last modified. So there is no equivalent for SQL Server's @@DBTS nor for MySQL's INFORMATION_SCHEMA.TABLES.UPDATE_TIME.

You also might be interested in this discussion:

http://archives.postgresql.org/pgsql-general/2009-02/msg01171.php

which essentially says: "if you need to know when a table was last modified, you have to add a timestamp column to each table that records that last time the row was updated".

Upvotes: 1

Related Questions