(Unique) Index erstellen

CREATE INDEX title_idx ON films (title);
CREATE UNIQUE INDEX title_idx ON films (title, year);
ALTER TABLE foo ADD PRIMARY KEY (x, y);

Foreign Key erstellen

 

CREATE TABLE products (

product_no integer PRIMARY KEY

);

CREATE TABLE orders (
    order_id integer PRIMARY KEY,
    product_no integer REFERENCES products (product_no),
    quantity integer
);