Some Examples of Tables with Primary Key and Foreign Key

Creating Table with Primary Key:
CREATE TABLE departments
( department_id number(10) NOT NULL,
department_name varchar2(50) NOT NULL,
CONSTRAINT departments_pk PRIMARY KEY (department_id)

Creating Table with Primary Key and Foreign Key:
CREATE TABLE employeesNew
( employee_number number(10),
employee_name varchar2(10),
department_id number(10),
salary number(6),
CONSTRAINT employees_pk PRIMARY KEY (employee_number),
CONSTRAINT fk_departments
FOREIGN KEY (department_id)
REFERENCES departments(department_id)

Creating Table With Primary Key:
supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)

If you don’t define a Primary Key While Defining the Table and later on you wish do it:
ALTER TABLE supplier
ADD CONSTRAINT supplier_pk PRIMARY KEY (supplier_id);

How to drop a Primary Key or Foreign Key Constraints:
ALTER TABLE table_name
DROP CONSTRAINT constraint_name;
Now we are dropping constraints defined in the above tables:
ALTER TABLE supplier
DROP CONSTRAINT supplier_pk;

ALTER TABLE departments
DROP CONSTRAINT departments_pk;