DROP TABLE IF EXISTS device_status; CREATE UNLOGGED TABLE device_status( device BIGINT PRIMARY KEY REFERENCES device, online BOOLEAN NOT NULL, timestamp TIMESTAMPTZ NOT NULL, host VARCHAR(1000) ); INSERT INTO device_status(device, online, timestamp) SELECT id, false, created_timestamp FROM device;