SQL statement How to insert data of date type in Oracle

Source: Internet
Author: User

Ext.: http://chwshuang.iteye.com/blog/933926

In development, it is often necessary to write a SQL statement to insert information into a table, insert the data if the field is a date type, you must convert the date type to a string literal in the SQL statement to insert the database. This is the only method of my field, if there is an expert please another enlighten!

My solution is to use the To_date () method in Oracle to see the following example

Inserting a date data code in Oracle

  1. INSERT INTO News (Id,msg,send_time,timer)
Inserting a date data code in Oracle
  1. VALUES (20110101,' Hello ', to_date (' 2011-2-28 15:42:56 ',' yyyy-mm-dd hh24:mi:ss '), sysdate);

When inserting a send_time, the To_date () method is used, the preceding argument is the string to be converted, is of type strings, followed by the previous date table Form, and Oracle uses the following format to parse the preceding string to generate the date type in the database.

Description: The ID field is a number type in the database, that is, type int, MSG is a string type is also a varchar2 type, Send_time is a date type, the timer is a date type, followed by a function in Oracle, Sysdate , the current date of a date type is automatically generated.

SQL statement How to insert data of date type in Oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.