I wanted to create table with unique date column. Is it possible?
I have following table:
CREATE TABLE senders (
id bigint NOT NULL,
number bigint NOT NULL,
inserted_at date NOT NULL
);
I want to be sure I will have unique values per date. For example I can insert (1, 1, '2017-01-01'),(1, 1, '2017-01-02') but I can't add then (1, 1, '2017-01-01') one more time. I tried using UNIQUE constraints creating table or unique indexes but always I have SQL unique exception.
CREATE UNIQUE INDEX senders_unique ON senders (id, number, inserted_at);
CREATE TABLE senders (
id bigint NOT NULL,
number bigint NOT NULL,
inserted_at date NOT NULL,
UNIQUE(id, number, inserted_at)
);
Is it possible. Thanks for all answers.