主流数据库 DATE 类型适用指南

来源:互联网 发布:c语言高级编程有什么 编辑:程序博客网 时间:2024/06/05 07:20

1, ORACLE

@public final static String ORACLE = "create TABLE date_type_test (date_t date, timestamp_t timestamp(3), interval_t interval YEAR TO MONTH)";

@public final static String ORACLE_INS = "insert into date_type_test values(SYSDATE,TO_TIMESTAMP('2004-4-9 22:59:43.234232222', 'YYYY-MM-DD HH24:MI:SS.FF'), INTERVAl '1-2' YEAR TO MONTH)";

2, DB2

@public final static String DB2 = "create TABLE datatypetest (date_t date, time_t time, timestamp_t timestamp)";
@public final static String DB2_INS = "insert into datatypetest values('01/07/1999', '12:12:23','2002-11-14-12.12.23.00') ";

3, INFORMIX

 public final static String INFORMIX = "create TABLE date_type_test (date_t date, datetime_t datetime year to fraction(5), interval_t interval year to month)";
   public final static String INFORMIX_INS = "insert into date_type_test values('1999-07-01', '1999-07-01 12:00:00.00001','1-1')";

4,SQLSERVER

###timestamp is not a date type.

public final static String SQLSERVER = "create TABLE date_type_test (smalldatetime_t smalldatetime, datetime_t datetime)";
   public final static String SQLSERVER_INS = "insert into date_type_test values ('12:00:01', '01/07/1999')";
 

5, MYSQL

  public final static String MYSQL = "create TABLE date_type_test (date_t date, time_t time, year_t year, datetime_t datetime, timestamp_t timestamp)";
   public final static String MYSQL_INS = "insert into date_type_test values( '1999-07-01','12:00:01', '2006','2006-03-24 12:00:00', '20060324120000')";

6, sybase

###timestamp is returned as a binary array

  public final static String SYBASE = "create TABLE date_type_test (smalldatetime_t smalldatetime, datetime_t datetime, timestamp_t timestamp)";
   public final static String SYBASE_INS = "insert into date_type_test  values('1999-04-01 12:00:00','1999-04-01 12:00:00','1')";