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.
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.
The following command is used to insert values into the table. Query: SET DATEFORMAT dmy; INSERT INTO GFG_user (Id, Dt, Address) VALUES ('1','23.11. 2021', 'German');
INSERT INTO Syntax 1. Specify both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3, ...)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With