During development, you often need to write an SQL statement to insert information into the table. If the inserted data field is of the date type, you must convert the date type to the string type and insert it into the database using SQL statements. This is the only method of my field. If you have any questions, please kindly advise!
My solution is to use the to_date () method in Oracle. For more information, see the example below.
Insert Date data in OracleCode
- Insert into news (ID, MSG, send_time, timer)
Insert Date data code in Oracle
- Values (20110101, '', To_date ('2017-2-28 15:42:56', 'yyyy-mm-dd hh24: MI: ss'), sysdate );
When you insert send_time, The to_date () method is used. The preceding parameter is the string to be converted. It is of the string type, followed by the date table format, oracle parses the preceding string in the following format to generate the date type in the database.
Note: The ID field is of the number type in the database, that is, int type. MSG is of the string type, varchar2 type, send_time is of the date type, and timer is also of the date type, A function in Oracle, sysdate, is used to automatically generate the current date of the date type.