pk_implicit_constraints1.htm

Objective : PRIMARY KEY will create implicit index

Note : while creating the table emp2, I did not add NOT NULL constraints.

 Script: 
DROP TABLE IF EXISTS emp2;
CREATE TABLE emp2
(
eid integer, fname text NOT NULL,
lname text NOT NULL, job varchar(10) NOT NULL, 
deptno integer NOT NULL,
hired date NOT NULL,released date, 
salary real,comm real,
CONSTRAINT emp2_pkey PRIMARY KEY (eid)
)
WITH (
OIDS=FALSE
);
ALTER TABLE emp2
OWNER TO manas237;

 

Message :

NOTICE: table "emp2" does not exist, skipping
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "emp2_pkey" for table "emp2"
Query returned successfully with no result in 344 ms.

 

Table emp2 (re-created ) and now note that primary key added a constraint "NOT NULL" to the field "eid " of emp2 table.