Which is equivalent to timestamp / rowversion (SQL Server) with PostgreSQL

Can someone help me find the equivalent of Timestamp / Rowversion (SQL Server) with PostgreSQL?

I am using NHibernate in Mono (UNIX).

I think Timestamp (PostgreSQL) is the equivalent of Datetime (SQL Server) - this is not what I'm looking for .

Edit 1: for those who don't know what Timestamp / Rowversion in SQL Server is: http://msdn.microsoft.com/en-us/library/ms182776.aspx (This is mainly used for optimistic concurrency)

+4
source share
4 answers

If I understand correctly that rowversion is the same as serial ? If not, you will have to create your own triggers.

0
source

See the system column section in the PostgreSQL documentation. In particular, xmin may be what you are looking for.

But be careful using any system columns. They are, by definition, implementation specific, and the details of some of them may change with future versions.

+4
source

You can create it manually:

  • Create sequence
  • Create a trigger to insert and update for each table containing a rowversion column.
  • Set rowversion column from sequence
0
source

The main thing that is missed is that the type of the version of the line changes every time the line is updated, even if the net result is this, the line does not change.

 CREATE TABLE MyTest (myKey int PRIMARY KEY ,myValue int, RV rowversion); GO INSERT INTO MyTest (myKey, myValue) VALUES (1, 0); GO INSERT INTO MyTest (myKey, myValue) VALUES (2, 0); GO select * from MyTest Go update MyTest set myValue = 0 go /* row version will have changed */ select * from MyTest Go 

The only choice I found was to create an update trigger.

0
source

All Articles