oracle- common sql statements and functions

1. seeking string length

- calculation function of the length of the string
select length ( 'Hello World!') Len from dual;

2. Common Functions

- DBMS_RANDOM.VALUE (1,7) results acquired random number between (1,7) is: 3.38380283953849        
SELECT DBMS_RANDOM.VALUE ( . 1 , . 7 ) from Dual     
 - acquiring a random number 
SELECT dbms_random.random from Dual       

- NVL meaning: NVL (expr1, expr2) if the first parameter is empty oracle then display the value of the second parameter if the first parameter is not empty, then the first parameter value of the original. 
SELECT NVL ( '' , . 4 ) from Dual; 

- obtaining the divisor and remainder sign is consistent with the results: -1 
SELECT MOD ( - 10 , . 3 ) from Dual 

- seeking integer results: 2 
SELECT Floor ( 10 / . 4 ) from Dual 

- Time formatting -> to a string 
select TO_CHAR (SYSDATE, ' YYYY the MM-dd-HH: mm: SS ' ) from Dual 

- string into a log format 
select TO_DATE ( ' 2019-08-16 ' , ' YYYY-the MM-dd ' ) from Dual 

- get the current time database 
SELECT SYSDATE from Dual 

- LPAD length of the string matching process 
- represents a total of 6 bits, is less than in the left adding side T 
SELECT LPAD ( ' Test ', . 6 , ' T ' )   from Dual - TTtest 


- if the total exceeds a predetermined length of 2, taken from left to right length 
SELECT LPAD ( ' Test ' , 2 , ' T ' )   from Dual - TE 

- || is string concatenation 
SELECT  ' 00 ' || TO_CHAR (SYSDATE, ' YY ' ) ||  ' 101 '  from Dual 

- SYSDATE subtraction is based on the addition and subtraction in days, seconds / 60 min / 60 hr / 24 days = the second day into
select (sysdate -1/24/60),sysdate from dual
 
 --返回最小值
select least(300, 600,26) from dual;

 

Guess you like

Origin www.cnblogs.com/newAndHui/p/11441775.html