The current system insertion time for Oracle, Db2, SqlServer, and MySQL databases.
I often encounter the following problems due to lack of knowledge about the time when the database is inserted into the system when I am working on a yibui Network Project:
1, java. SQL. SQLException: ORA-01861: Text and format strings do not match,
Cause: the retrieved system time type is incorrect. It should be 'invalid date '.
Next we will introduce the time when Oracle, Db2, SqlServer, and MySQL databases are inserted into the current system.
For example, a table has two fields: name and makedate.
1. oracle:
The system insertion time should be sysdate:
Insert into table (name, makedate) values ('test', sysdate );
2. Db2:
The system insertion time should be current timestamp and the makedate data type should be timestamp.
Insert into table (name, makedate) values ('test', current timestamp );
3. SqlServer:
The system insertion time should be GETDATE ()
Insert into table (name, makedate) values ('test', GETDATE ());
4. MySQL:
The system insertion time should be:
Now (): Use 'yyyy-mm-dd hh: mm: ss' to return the current date and time, which can be directly stored in the datetime field.
Curdate (): the format of 'yyyy-mm-dd' returns the date of today, which can be saved directly to the date field.
Insert into table (name, makedate) values ('test', now ());