小数点以下の桁数を扱ういくつかのoracle関数について

2636 ワード

1.           
select round(1.2345, 3) from dual;
  :1.235
2.       ,  
select trunc(1.2345, 2) from dual;
  :1.23

select trunc(1.2399, 2) from dual;

  :1.23
3.   
       x     :  
        SQL>         select         ceil(23.33)         from         dual;  
  :   24 

 

       x     :  
        SQL>         select         floor(23.33)         from         dual;  
  :   23  
   
          y  x :rcund(x,[y])  
        SQL>         select         round(23.33)         from         dual;  
  :    23  
   
     y    x :trunc(x,[y])  
        SQL>         select         trunc(23.33)         from         dual;  
  :   23 


     

 The following are number examples for the to_char function.


  to_char(1210.73, '9999.9') would return '1210.7'
  to_char(1210.73, '9,999.99') would return '1,210.73'
  to_char(1210.73, '$9,999.00') would return '$1,210.73'
  to_char(21, '000099') would return '000021'


to_char      
  to_char(sysdate,'d')      
  to_char(sysdate,'dd')      
  to_char(sysdate,'ddd')      
  to_char(sysdate,'ww')      
  to_char(sysdate,'mm')      
  to_char(sysdate,'q')      
  to_char(sysdate,'yyyy')  
                   
  SQL> select to_char(to_date('20070101','yyyymmdd'),'d') from dual;

1.instr

 

 Oracle/PLSQL ,instr                    。

 

    :instr( string1, string2 [, start_position [, nth_appearance ] ] )

 

string1     ,         。

string2   string1       .

start_position   string1          。     ,       1.       1  。       ,        ,       ,      ,                    。

 

nth_appearance            string2.      ,    ,    1.          。


  :

  String2 String1     ,instr    0.

 

   :

Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
    :

select instr('abc','a') from dual;    --    1 
select instr('abc','bc') from dual; --    2
select instr('abc abc','a',1,2) from dual; --    5
select instr('abc','bc',-1,1) from dual; --    2
select instr('abc','d') from dual; --    0