Oracle single row Functions

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.