Oracle以å¤ã®SQLã§SYSDATEãåå¾ããæ¹æ³
ã¯ããã«
æ¥åã§ã¯Oracleã使ãäºãå¤ããã§ããããã¾ã«DB2ã使ã£ãããã¾ãã
ãããªæã«ä¸çªå°ãã®ããåDBMSã§å¾®å¦ã«SQLã®è¨è¿°ãç°ãªãäºã§ãã
æè¿ã¯SQLiteã使ã£ã¦ãããã§ãããOracleã¨ãDB2ã¨ãSQLã®è¨è¿°ãç°ãªãäºããã£ããããã®ã§ãããã«æ··ä¹±ãã¦ãã¾ãã
SQLã¯ä¸å¿DBã®æ¨æºèªã ãã©ãçµæ§æ¹è¨ã使ããã¦ããããã¨ããã®ãä»åã®ã話ã
Â
çµè«
Oracle
SELECT SYSDATE FROM DUAL;
DB2
SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1;
MySQL
SELECT CURRENT_DATE;
SQLite
SELECT CURRENT_DATE;
SQL Sever
SELECT CONVERT ( date, SYSDATETIME() );
Â
çµç·¯
SQLiteã§ã·ã¹ãã æ¥ä»ãåå¾ãããã¨ããã¨ããå®ã¯ã©ãæ¸ãããè¯ãã®ãç¥ããªãäºã«æ°ã¥ãã
ã¡ãªã¿ã«Oracleã®å ´åã¯ã以ä¸ã®éãã¨ãªããï¼DUALã¯ããã¼è¡¨ï¼
select sysdate from dual;
Â
DB2ã®å ´åã ã¨ã以ä¸ã®éãã¨ãªããï¼SYSDUMMY1ã¯ããã¼è¡¨ï¼
select current date from sysibm.sysdummy1;
Â
調ã¹ãã¨ãããSQLiteã§ã¯ãcurrent_dateãã§ã·ã¹ãã æ¥ä»ãåãããããã
ï¼ã¡ãªã¿ã«DB2ã¨ã¯ã¢ã³ãã¼ã¹ã³ã¢ã®æç¡ãå¾®å¦ã«éãï¼
Â
ããã§ä»¥ä¸ã®éãã«å®è¡ããã¨ãããã¨ã©ã¼ã§æãããï¼
sqlite> select current_date from dual;
Error: no such table: dual
Â
ããããããã¼è¡¨ã¯ã©ãæ¸ããã ãï¼ãã¨ãã¬æ°å³ã«èª¿ã¹ã¦ããã¨ã
ã©ãããSQLiteã§ã¯ããã¼è¡¨ã®æå®ã¯ä¸è¦ãããã
Â
ä»åº¦ã¯ä»¥ä¸ã®éãã«å®è¡ããã¨ãããç¡äºåå¾ã§ãã¾ããããã§ãããã§ããã
sqlite> select date();
2015-06-07
Â
ã¾ã¨ã
ã¡ãªã¿ã«SQL Serverã«ã¯æ¥ä»ã®ã¿ãè¿ãé¢æ°ã¯ç¡ãããããå¤æãå¿ é ã®ããã§ãã
Â
ã·ã¹ãã æ¥ä»ä¸ã¤åã£ã¦ããããã ãè¨è¿°ãç°ãªãããã§ãããã
è¤æ°ã®DBMSã«å¯¾å¿ããSQLéå¼ãè¾å ¸ã¿ãããªã®ãããã¨ä¾¿å©ãªãã§ããã©ãã
ï¼ç¾ç¶ã§ã¯ãã®æ¬ã§ããããã詳ããè¦ã¦ãªãã®ã§ãããã¾ããããï¼