ORA-01400: cannot insert NULL into (“SYS”.”tablenamr”.”columnname”)

I created a table with PRIMARY KEY CONSTRAINT on a column. I tried inserting value into the table leaving the primary key column value as null. I got this error.
SQL> create table employee(
2 employee_id int primary key,
3 manager_id int,
4 department_id int,
5 first_name varchar2(20),
6 last_name varchar2(20),
7 email varchar2(30),
8 phone_number number(20),
9 hire_date date,
10 job_id int,
11 salary number,
12 commission_pct number);
Table created.
SQL> select * from employee;
no rows selected
SQL> insert into employee(first_name) values (‘learnersreference’);
insert into employee(first_name) values (‘learnersreference’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SYS”.”EMPLOYEE”.”EMPLOYEE_ID”)
This issue can be fixed in two ways :
1) Insert value into the Primary Key Column
SQL> insert into employee(employee_id,first_name) values (1,’learnersreference’);
1 row created.
2) Drop the Primary Key Constraint
SQL> alter table employee drop primary key;
Table altered.
SQL> insert into employee(first_name) values (‘learnersreference’);
1 row created.

Free Oracle Database Articles, Tips, Jobs :

Delivered by FeedBurner