I have the following DDL and DML statements :
create table emp_details (
ID number(2) constraint t_pk primary key,
F_Name varchar(10) not null,
L_Name varchar(10) not null,
DOB date,
Mob_no number(10),
City varchar(10),
PIN number(5),
Gender char(1),
Designation varchar(15),
Join_Date date,
);
insert into emp_details values (01,'John','Wick','1990-07-05',9856482358,'Goa',403001,'M','SDE II', '2015-01-08');
then, I get the error of ORA-01843. So, what could be the problem?
The easiest thing to do here is to use ANSI date literals instead of strings for the dates (using strings will depend on the value of
NLS_DATE_FORMATand you don't want to play around with that if you don't have to):I have to add that explicitly listing the columns into which you're inserting values is a good habit to have. Otherwise, your
INSERTquery will break if you or someone else adds a column from your table:Last, another good practice is to use
VARCHAR2instead ofVARCHARwhen you're working with Oracle. Currently they work the same, but Oracle "reserves the right" to changeVARCHARto meet with the ANSI standard under whichNULLvalues and the empty string won't be the same (withVARCHAR2they will always be the same). IOW, the behavior ofVARCHARvalues in Oracle can change.