查看nls参数
select * from nls_database_parameters
select * from nls_instance_parameters
select * from nls_session_parameters
修改nls参数
alter session set nls_date_format = 'YYYY-MM-DD'
alter instance ...
alter database ...

解决方案 »

  1.   

    其实你不用区修改数据库上的日期格式,因为在底层,存储时间实际上都是整数,日期格式是由显示这个日期的环境来确定的,如果你是通过windows来访问数据库的,那就在windows中加一个环境变量(NLS_DATE_FORMAT)来指定客户端日期的格式就可以了,我现在用的是这中
    NLS_DATE_FORMAT = yyyy-mm-dd hh24:mi:ss ,显示的效果是 2003-7-5 10:31
      

  2.   

    还有,你也可以把这个环境变量当作一个注册表的键值,添加倒 注册表中 oracle 的那部分中
      

  3.   

    修改nls参数
    alter session set nls_date_format = 'YYYY-MM-DD'
    alter instance ...
    alter database ...能不能写的详细点,我是菜鸟
      

  4.   

    zhangjs780206 : 为什么不试一试我的方法呢?
      

  5.   

    session是指进程,instance是指实例,database是指数据库alter 的语法都是一样的,只不过修改的层次和范围不一样。根据你的需要决定选用那个层次的语句。
      

  6.   

    如果要修改spfile中的初始参数可以通过两种方法进行修改:
    通过命令行进行修改:
    Setting or Changing Initialization Parameter Values
    Use the SET clause of the ALTER SYSTEM statement to set or change initialization
    parameter values. Additionally, the SCOPE clause specifies the scope of a change as
    described in the following table:
    Managing Initialization Parameters Using a Server Parameter File
    2-48 Oracle9 i Database Administrator’s Guide
    It is an error to specify SCOPE=SPFILE or SCOPE=BOTH if the server is not using a
    server parameter file. The default is SCOPE=BOTH if a server parameter file was
    used to start up the instance, and MEMORY if a traditional initialization parameter
    file was used to start up the instance.
    For dynamic parameters, you can also specify the DEFERRED keyword. When
    specified, the change is effective only for future sessions.
    A COMMENT clause allows a comment string to be associated with the parameter
    update. When you specify SCOPE as SPFILE or BOTH, the comment is written to the
    server parameter file.
    The following statement changes the maximum number of job queue processes
    allowed for the instance. It also specifies a comment, and explicitly states that the
    change is to be made only in memory (that is, it is not persistent across instance
    shutdown and startup).
    ALTER SYSTEM SET JOB_QUEUE_PROCESSES=50
    COMMENT='temporary change on Nov 29'
    SCOPE=MEMORY;
    SCOPE Clause Description
    SCOPE = SPFILE The change is applied in the server parameter file only. The
    effect is as follows:
    n For dynamic parameters, the change is effective at the next
    startup and is persistent.
    n For static parameters, the behavior is the same as for
    dynamic parameters. This is the only SCOPE specification
    allowed for static parameters.
    SCOPE = MEMORY The change is applied in memory only. The effect is as follows:
    n For dynamic parameters, the effect is immediate, but it is
    not persistent because the server parameter file is not
    updated.
    n For static parameters, this specification is not allowed.
    SCOPE = BOTH The change is applied in both the server parameter file and
    memory. The effect is as follows:
    n For dynamic parameters, the effect is immediate and
    persistent.
    n For static parameters, this specification is not allowed.
      

  7.   

    方法2:通过修改原始的参数文件init$instance.ora后,用命令转换生成相应的spfile文件,然后用生成的spfile来启动数据库.
    1)修改init$instance.ora
    2)用create spfile命令生成 spfile
    example1:生成默认的 spfile
    CREATE SPFILE FROM PFILE='/u01/oracle/dbs/init.ora';
    example2:指定生成的spfile的确名称
    CREATE SPFILE='/u01/oracle/dbs/test_spfile.ora'
           FROM PFILE='/u01/oracle/dbs/test_init.ora';
      

  8.   

    谢谢大家,我的这种写法可以吗
    create or replace trigger data_logon_trigger 
    after logon 
    ON DATABASE 
    begin 
        execute immediate 
            'alter session set nls_date_format = ''yyyy-mm-dd hh24:mi:ss'' '; 
    end; 
      

  9.   

    zhangjs780206() :
    大哥,我前面不是说了,不管你怎么规定格式,数据库存到数据文件中的日期格式都是一样,你设置这个环境变量只是为了显示时间的时候按照你规定的方式显示而已,所以,你写这个trigger没有必要,你只要在你需要在oracle的客户端设置这个变量就可以了
      

  10.   

    wxdsun(影子):
    你可能不了解情况,我设置的目的不是为了显示,而是为了客户端(javascript)传递日期型参数