Oracle use (1) Oracle database uses TIMESTAMP() type to query data

1. At the beginning, use PLSQL Developer to execute the following SQL statement:

 

select billsell.CREATE_TIME
  from BILL_SELL billsell
 WHERE billsell.STATUS <> 9
   AND billsell.ACTIVE_FLAG = 0
   AND billsell.STATUS = 2
   AND billsell.CREATE_TIME >=
       to_timestamp('2015-06-11 15:50:04.0', 'yyyy-mm-dd hh24:mi:ss.ff')
   AND billsell.INDUSTRY_ID = 1
 ORDER BY billsell.CREATE_TIME DESC;

 

The results show that:

 

2 Display optimization

1> Add environment variables

A If adding system environment variable (name) NLS_TIMESTAMP_FORMAT = (value) YYYY-MM-DD HH24:MI:SS:FF6

Then the result is displayed as:

B If adding system environment variable (name) NLS_TIMESTAMP_FORMAT = (value) YYYY-MM-DD HH24:MI:SS (recommended)

Then the result is displayed as:

 

pay attention: 

1. After the environment variables are added, PLSQL Developer must be restarted to be effective.

        2. If you are querying timestamp type data, you need to use to_timestamp (parameter value, date format) to replace.

 

For example 1  

If the timestamp type data (2015-06-24) is directly inserted in the database, the default in the database is: 2015-06-24 00:00:00

If you want to query the data of 2015-06-24, there are two ways

The first is     

begintime <  to_timestamp('2015-06-25', 'yyyy-mm-dd hh24:mi:ss.ff') 

 

The second   

 

begintime <=  to_timestamp('2015-06-25', 'yyyy-mm-dd hh24:mi:ss.ff') ++0.99999

 

For example 2

Query from the database:

select to_timestamp('2015-06-25', 'yyyy-mm-dd hh24:mi:ss.ff')+0.99999 from  dual

See the result as:

 

 

If you want to check the data as of noon on 2015-06-25:

 

 select  to_timestamp('2015-06-25', 'yyyy-mm-dd hh24:mi:ss.ff')+0.5 from  dual

See the result as:

 


 

 

Guess you like

Origin blog.csdn.net/xiaokanfuchen86/article/details/113268721