Unique constraint

    0

    2

    SQL recipes

    Unique constraint when creating a table

    Example of table

    CREATE TABLE notifications_sent(
     user_id INT NOT NULL REFERENCES users(id),
     notification_identifier INT NOT NULL,
     ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     UNIQUE (user_id, notification_identifier)
    );
    
    UNIQUE (col1, col2)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.