How to insert date values into table

0 votes

How do I insert into table with different  date datatype?

insert into table(id,fullname,dob)values(%id,'%name',[what should be written here?]);

I am working on oracle 10g

Feb 18 in Database by Neha
• 8,560 points
79 views

1 answer to this question.

0 votes

You have to convert the literal to DATE with the help of TO_DATE since DOB is DATE data type.

TO_DATE('', '<format_model>')


For example,

SQL> CREATE TABLE t(dob DATE);


Table created.

SQL> INSERT INTO table(dob) VALUES(TO_DATE('01/10/2018', 'DD/MM/YYYY'));


1 row created.

SQL> COMMIT;


Commit is complete.

SQL> SELECT * FROM table;


DOB
----------
01/10/2018
A DATE data type contains both date and time elements. If you're not concerned about the time portion, then you'll also use the ANSI Date literal which uses a hard and fast format 'YYYY-MM-DD' and is NLS independent.
For example,

SQL> INSERT INTO t(dob) VALUES(DATE '2015-12-17');

1 row created.

answered Feb 18 by Vaani
• 7,020 points

Related Questions In Database

0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,380 points
1,665 views
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
710 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
16,258 views
0 votes
1 answer

How to check if a table exists in a given schema

Since you havent mentioned the DBMS in ...READ MORE

answered Oct 4, 2019 in Database by Daric
• 500 points
1,872 views
0 votes
1 answer

Automating Oracle script with nolio

Depending upon the details of your script ...READ MORE

answered Jul 17, 2018 in Other DevOps Questions by ajs3033
• 7,280 points
325 views
0 votes
1 answer

Is there any boolean type in Oracle database?

Nope. I don't think there is one But ...READ MORE

answered Oct 10, 2018 in Database by Neha
• 6,300 points
290 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9 in Database by Neha
• 8,560 points
72 views
0 votes
1 answer

Please name some online websites to compile and run PL/SQL?

For executing Oracle SQL queries and PL/SQL ...READ MORE

answered Feb 11 in Database by Neha
• 8,560 points
80 views
0 votes
1 answer

How to calculate age (in years) based on Date of Birth and getDate()

Following can be a solution to your ...READ MORE

answered Feb 23 in Database by Vaani
• 7,020 points
65 views
0 votes
1 answer

How to take user input in livesql.oracle.com in PLSQL?

To create a procedure with a parameter ...READ MORE

answered Feb 7 in Database by Vaani
• 7,020 points
969 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP