alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'

解决方案 »

  1.   

    如果要每次进入 sqlplus 的时候都自动进行这样的修改的话,可以修改 $ORACLE_HOME/sqlplus/admin/glogin.sql 文件,在其中加上这句话,但是注意跟上分号和一个空行,好自动执行。
      

  2.   

    sqlplus 每次启动的时候,都会首先执行 glogin.sql 文件,所以有什么需要 sqlplus 替你先执行的,都可以放进去,当然前提条件是有效的,在 sqlplus 中能执行的东东
      

  3.   

    大家误会了,我是要修改oracle数据库里面的日期存储格式,而不是简单的通过sqlplus改变显示。
      

  4.   

    Oracle里面怎么存储的和你应该没什么关系啊。你只要在读取的时候更改格式就可以了。在内部可能是以浮点存储的吧。
      

  5.   

    作为oracle的用户你只能修改显示,你无需关心 oracle 是如何存储此种数据类型的,而且就是你想关心,oracle 也不会让你知道的,哈哈哈哈,oracle 可不是开源项目!!!!再说了,wjmmml,这个帖子的楼主不是你吧?
    getnull 你是怎么理解的?
      

  6.   

    如果你真的是要在所有的地方都显示你的格式,那么你可以把Oracle的初始参数NLS_DATE_FORMAT改了就可以了。
      

  7.   

    wjmmml,悄悄的告诉姐姐,你的三颗星怎么得来的?是不是盗用别人的?还是用 n 个账号倒分?
      

  8.   

    我的星怎么来的。好象不关你的事。
    我的问题是这样的。正常开发下,根本就不用关心oracle的日期存储格式,但是我们用了一个糟糕的报表,他要求输入的参数必须和数据库的实际存储格式一致。我使者把传近来的蚕食和数据库中的数据同to char转换,然后比较,但是报表出错。所以我必须改变oracle的日期存储格式。另外。我和getnull是一个公司的。
    我们遇到了这个问题,请oracle高手指教。
      

  9.   

    让传进来的参数是日期型,不管是什么的日期型,delphi, vc or any other tools,都可以,但是你得保证是日期。否则,他输乱七八糟的东西你怎么控制?该用 to_char 的地方,用 to_char;
    该用 to_date 的地方,用 to_date。to_char(fieldname, 'yyyy-mm-dd hh24:mi:ss') = to_char(paraname, 'yyyy-mm-dd hh24:mi:ss')let me think, maybe ok, maybe not. Not sure. just FYI
      

  10.   

    那就让报表参数为字符,固定格式的字符,用
    to_char(fieldname, 'AsYourParaFormatString') = paraname
      

  11.   

    paste your report format pls. and the sql statement you used, even failed.
      

  12.   

    or you can use the "alter session" following the "connect" statement.
    then use the database field and the parameter directly. I think you don't need to modify the others.
    The following is the test case in sqlplus, I think it should be the same as in the other development tools.you should use 单引号read the following case carefully, maybe it can be helpful to you. and wish so.SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi;ss';会话已更改。SQL> select * from dual where sysdate = '23';
    select * from dual where sysdate = '23'
                                       *
    ERROR 位于第 1 行:
    ORA-01840: input value not long enough for date formatSQL> select * from dual where sysdate = '2003-06-21 02:06:54';未选定行SQL> alter session set nls_date_format='yyyy.mm.dd';会话已更改。SQL> select * from dual where sysdate = '2003.06.21';未选定行SQL> select * from dual where sysdate = '2003-06-21 02:06:54';
    select * from dual where sysdate = '2003-06-21 02:06:54'
                                       *
    ERROR 位于第 1 行:
    ORA-01830: date format picture ends before converting entire input stringSQL> select * from dual where sysdate = 2003.06.21;
    select * from dual where sysdate = 2003.06.21
                                              *
    ERROR 位于第 1 行:
    ORA-00933: SQL command not properly ended
      

  13.   

    你这只是改变了session的格式,我要全局的。
      

  14.   

    “如果你真的是要在所有的地方都显示你的格式,那么你可以把Oracle的初始参数NLS_DATE_FORMAT改了就可以了”
      

  15.   

    did you try it?
    if it could work, you could change your code according to it, I think.if you want the GLOBAL, try add the nls_date_format in your init.ora file, then reboot your database, and test.
      

  16.   

    在oracle9i中找不到init.ora 这个文件。
      

  17.   

    在init数据库SID.ora中加
    NLS_DATE_FORMAT =
      

  18.   

    在server端修改init.ora 这个文件,设nls_date_format='yyyy-mm-dd hh24:mi:ss'
    这个会影响整个数据库,建义通知管理员。在注册表:hkey->software->oracle,找到nls_date_format,设置其值
    这个只影响客户端显示
      

  19.   

    服务器端注册表HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE->HOME0中NLS_DATE_FORMAT变量为日期格式的值。
    没有可以右击鼠标“增加”一字串,使其值赋为:'yyyy-mm-dd hh24:mi:ss'
      

  20.   

    我的操作系统就是win2000啊。
      

  21.   

    可能安装oracle时改了名字,init010... .ora,就是init后与一串数字相连的