Oracle modify the default system time format

Oracle's first day of learning

tips: Change the default system time display format

Previously, by changing the registry and adding the environment variable NLS_LANG, the desired effect was not achieved, and there was no change. Maybe my operation was wrong.

Then I tried several methods that Baidu found, and finally reached the goal by operating as follows.

 

test environment:

OS         windows10 v1909

Oracle    11.2.0.1.0 - 64bit

Tool      Oracle自带SQLPlus

 

My target format is: yyyy-mm-dd hh24:mi:ss 

First, the first step is to query the default time format in the system

Originally, before this step, a time format output by sqlplus should be intercepted. I forgot to write the learning record for the first time. The format is similar to the following:

The format of dd-mm-yyyy.

SQL>select sysdate from dual;

 

The second step, log in to sqlplus, change the default time format

1. SQL>sqlplus /nolog

2. SQL>conn sys/sys@orcl as sysdba;

3. SQL>alter system set nls_date_format = 'yyyy-mm-dd hh24:mi:ss' scope=spfile;

System Altered.

4. SQL> shutdown immediate; - After this step is completed, you need to wait for a while, depending on the performance of the Oracle data machine, the length varies

ORACLE instance shut down.

5. SQL>startup; - After the instance shutdown prompt appears, you can start the Oracle instance again

ORACLE instance started.

An error may appear when restarting the instance: The database instance is not started. At this time, you need to manually start the service.

When I manually restarted, the service marked with the red line below could not be opened: an error was reported that the windows service could not be opened

I had no choice but to restart my old machine, and it was successfully turned on after the restart.

6. SQL>select sysdate from dual; --After restarting the instance, query the system time again, and it has become the format I want.

SYSDATE
-------------------
2021-01-05 08:22:54

OK, reach the goal.

 

 

 

Guess you like

Origin blog.csdn.net/Ezreal_XLove/article/details/112197586