多列约束格式的示例

以下示例创建了一个名为 order_items 的标准表,它有一个使用多列约束格式的名为 items_constr 的唯一约束:
CREATE TABLE order_items
          (
          order_id SERIAL,
          line_item_id INT not null,
          unit_price DECIMAL(6,2), 
          quantity INT, 
          UNIQUE (order_id,line_item_id) CONSTRAINT items_constr
          );

有关约束名称的信息,请参阅声明约束名称