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, 2022 in Database by Neha
• 9,060 points
2,792 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, 2022 by Vaani
• 7,060 points

Related Questions In Database

0 votes
1 answer

How to Insert date value in SQL table

Always use ANSI default string literal format for date i.e. YYYY-MM-DD like below. INSERT ...READ MORE

answered Feb 17, 2022 in Database by Neha
• 9,060 points
169,043 views
0 votes
0 answers

How to convert date into timestamp in SQL query?

I'm attempting to move data from the ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,010 points
1,472 views
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,370 points
2,137 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
1,212 views
0 votes
0 answers

Convert timestamp to date in Oracle SQL

How can we convert timestamp to date? READ MORE

Aug 29, 2022 in Database by Kithuzzz
• 38,010 points
779 views
0 votes
1 answer

CASE .. WHEN expression in Oracle SQL

Use an IN clause. Example: SELECT status, CASE ...READ MORE

answered Sep 17, 2022 in Database by narikkadan
• 63,720 points
438 views
0 votes
1 answer

How to find top three highest salary in emp table in oracle?

Use this: SELECT *FROM ...READ MORE

answered Sep 18, 2022 in Database by narikkadan
• 63,720 points
8,067 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,300 points
856 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, 2022 in Database by Vaani
• 7,060 points
1,384 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, 2022 in Database by Vaani
• 7,060 points
3,923 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP