Re: why it has error ?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 28 Dec 2001 07:39:32 -0800
Message-ID: <a0i3nk013mh_at_drn.newsguy.com>


In article <a0ghgn$atr$1_at_mail.cn99.com>, "cok" says...
>
>hi ,
>
>This is my SQL sentence :
>
>
>create table MyTable
>(
> column_1 date default '2001/01/01'
>)
>
>but it has error about:
>
>default '2001/01/01'
>
>why ?????
>
>what can I do ?
>
>

because 2001/01/01 is just a string, it tries to convert the string into a date and it cannot.

ops$tkyte_at_ORA815.US.ORACLE.COM> create table MyTable   2 (
  3 column_1 date default '2001/01/01'   4 )
  5 /
    column_1 date default '2001/01/01'

                                   *

ERROR at line 3:
ORA-01861: literal does not match format string

ops$tkyte_at_ORA815.US.ORACLE.COM> create table MyTable   2 (
  3 column_1 date default to_date( '2001/01/01', 'yyyy/mm/dd' )   4 )
  5 /

Table created.

always TO_DATE() strings with the appropriate date mask, ALWAYS.
>
>

--
Thomas Kyte (tkyte_at_us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Fri Dec 28 2001 - 16:39:32 CET

Original text of this message