How can I insert into table with different input using / ,with date datatype?
insert into run(id,name,dob)values(&id,'&name',[what should I write here?]);
I'm using oracle 10g.
Since dob
is DATE
data type, you need to convert the literal to DATE
using TO_DATE
and the proper format model. The syntax is:
TO_DATE('<date_literal>', '<format_model>')
For example,
SQL> CREATE TABLE t(dob DATE);
Table created.
SQL> INSERT INTO t(dob) VALUES(TO_DATE('17/12/2015', 'DD/MM/YYYY'));
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM t;
DOB
----------
17/12/2015
A DATE
data type contains both date and time elements. If you are not concerned about the time portion, then you could also use the ANSI Date literal which uses a fixed format 'YYYY-MM-DD'
and is NLS independent.
For example,
SQL> INSERT INTO t(dob) VALUES(DATE '2015-12-17');
1 row created.