UNIQUE (col1, col2)
      

      Sql language logo
      Unique constraint

      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)
      );
      

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.