Tag : postgres

pgSQL vs T-SQL – Database Shrinking to reclaim space for the OS

Databases typically grow over time. One occasion where they may counter that trend is if obsolete data is permanently removed. In Postgres, Dropping or Truncating a table does clear its data file on disk (see $PGDATA/base/YourDbOID/ ). However in SQL Server it doesn’t. Nor does running a regular VACUUM in Postgres following bloat introduced from Updates and Deletes. Internally, the…

pgSQL vs T-SQL – Enforce uniqueness on a column but allow multiple nulls

A Unique constraint is used to enforce unique values across one or many columns, often applied against Alternate keys of a table. Sometimes you want uniqueness enforced only where data for a column is present, and not where values are Null, for example, when storing optional Person attributes such as National Insurance numbers or Driving Licence numbers. Section 5.3.3. Unique…