Oracle Entry second day (bottom)-Single-line function

Source: Internet
Author: User

I. Overview

  What is a single-line function:

Action data Object Accept parameter returns a result only one row is transformed each row returns a result that can be transformed data types can be nested parameters can be a column or a value

 

  For example, a grouping function is a typical multi-line function

   Classification:

  

second, character function

  Casing Control Functions:

LOWER ()--Convert to lowercase

    UPPER ()--Convert to uppercase

    Initcap ()--Capitalize first letter

SELECT LOWER('SQL Course'),UPPER('SQL Course'), Initcap ('SQL Course') fromdual;LOWER('Sqlcourse')UPPER('Sqlcourse') Initcap ('Sqlcourse')------------------ ------------------ --------------------SQL Course SQL Course SQL Course

  Dual is a continuation of the table, and again to remind SQL case insensitive, lower () is also allowed

  Character control functions:

CONCAT (' Hello ', ' world ')--Connection string

    SUBSTR (' HelloWorld ', 1,5)-take a substring, starting with subscript 1, fetch 5 (SQL subscript starting from 1 instead of 0)

    Length (' HelloWorld ')--Get the lengths

    INSTR (' HelloWorld ', ' W ')--The first occurrence of the position

    Lpad (salary,10, ' * ')--left-padded

    Rpad (Salary, ten, ' * ')--right-padded

    TRIM (' H ' from ' HelloWorld ')--Removes the specified character from the end

    Replace (' abcd ', ' B ', ' m ')--Replaces all characters (replaces B with M)

SELECTCONCAT ('HelloWorld','Jiangbei'), SUBSTR ('HelloWorld',1,5), LENGTH ('HelloWorld'), INSTR ('HelloWorld','W') fromdual; CONCAT ('HELLOWORLD','Jiangbei'SUBSTR ('HELLOWORLD',1,5) LENGTH ('HELLOWORLD') INSTR ('HELLOWORLD','W')------------------------------ ------------------------ -------------------- -----------------------Helloworldjiangbei HelloTen                       6
SELECTLpad (Salary,Ten,'*') fromemployees; Lpad (SALARY,Ten,'*')--------------------*****24000*****17000*****17000******9000******6000
SELECTTRIM ('H'  from 'h2h2h'),REPLACE('H2H2H2','H','M') fromdual; TRIM ('H' from'h2h2h')REPLACE('H2H2H2','H','M')-------------------- -------------------------2H2 m2m2m2
three, number function

  ROUND (45.926,2)--Rounding

  TRUNC (45.926,2)--truncation

  MOD (100,3)--seeking redundancy

SELECT ROUND(45.926,2), TRUNC (45.926,2), MOD ( -,3) fromdual;ROUND(45.926,2) TRUNC (45.926,2) MOD ( -,3)--------------- --------------- ----------          45.93           45.92          1

Oracle Entry second day (bottom)-Single-line function

Related Article

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.