Single-row functions are mainly divided into five types: The varchar2 function, the number function, and the date function,
Common functions,
Conversion functions
Character FunctionsThe main function is to operate string data, such:
. Upper (string and column): converts the input string to uppercase and returns the result;
. Lower (string and column): converts the input string to lowercase and returns the result;
. Initcap (string and column): upper-case letters at the beginning;
. Length (string, column): returns the length of the string;
. Replace (string, column): replace;
. Substr (string, column, start point [, end point]): String truncation;
Numeric FunctionsFor example:
. Round (number and column [number of digits retained]): rounding operation;
. Trunc (number and column): discard content at the specified position;
. Mod (number 1, number 2); modulo and remainder
Date Functions
Get current date: sysdate
select sysdate from dual;
. Last_day ()
. Next_dat (date, number of weeks)
. Add_months (date, number)
. Months_between (date 1, date 2)
Conversion functions
. To_char (string | column, Format String): converts a date or number to a string for display.
. To_date (string, Format String); Convert string to date data display
. To_number (string): converts a string to a number for display.
select TO_CHAR(sysdate,'yyyy-mm-dd'),TO_CHAR(sysdate,'yyyy') from dual
select TO_CHAR(sysdate,'fmyyyy-mm-dd'),TO_CHAR(sysdate,'yyyy') from dual
Remove the leading 0 of the date;
select TO_CHAR(sysdate,'hh24'),TO_CHAR(sysdate,'hh-mi-ss') from dual
Number formatting
select TO_CHAR(1222223,'999,999,999') from dual
Currency
select TO_CHAR(1222223,'L999,999,999') from dual
L (locale) Currency symbols in the current language environment
Common functionsFor example:
. Nvl () function, processing null
select NVL(money,0) from demo;
. Decode () function: multi-value judgment
Decode (column, judgment value 1, display value 1, judgment value 2, display value 2)