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,940 points
449 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
0 answers

How to convert date into timestamp in SQL query?

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

Aug 19 in Database by Kithuzzz
• 20,660 points
184 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,380 points
1,725 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
810 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
18,881 views
0 votes
0 answers

Convert timestamp to date in Oracle SQL

How can we convert timestamp to date? READ MORE

Aug 29 in Database by Kithuzzz
• 20,660 points
35 views
0 votes
1 answer

CASE .. WHEN expression in Oracle SQL

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

answered Sep 17 in Database by narikkadan
• 37,660 points
61 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 in Database by narikkadan
• 37,660 points
220 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
378 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
491 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
2,026 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