Skip to content

21st February 2022

Computer Science

GNULinux

PostgreSQL

  • New: Check that a string is a valid timezone.

    Use the constraint CHECK (now() AT TIME ZONE timezone IS NOT NULL). For example:

    CREATE TABLE locations (
        location_id SERIAL PRIMARY KEY,
        name TEXT,
        timezone TEXT NOT NULL CHECK (now() AT TIME ZONE timezone IS NOT NULL)
    );