Primary, Unique, Foreign Keys

Published October 06, 2026 By Sai Sree Ram Gundepudi

Key Constraints

PRIMARY KEY

CREATE TABLE employees (
  emp_id NUMBER PRIMARY KEY,
  name VARCHAR2(50)
);

UNIQUE

CREATE TABLE users (
  username VARCHAR2(30) UNIQUE
);

FOREIGN KEY

CREATE TABLE orders (
  order_id NUMBER PRIMARY KEY,
  emp_id NUMBER REFERENCES employees(emp_id)
);

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article