Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Description of C++ character function, number function and date function

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "the explanation of C++ character function, number function and date function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "C++ character function, number function and date function description" bar!

I. official files

Book → SQL Language Reference → 5 Functions → Single-Row Functions

Character function

Case conversion function

Function description UPPER syntax: UPPER (string) description: returns uppercase string. Characters that are not letters remain the same. If the string is of the CHAR data type, then the result is also of type CHAR. If string is of type VARCHAR2, then the result is also of type VARCHAR2. Example:

SELECT UPPER ('AaBbCcDd') "AaBbCcDd"

FROM DUAL

LOWER syntax: LOWER (string) description: returns lowercase string. Characters that are not letters remain the same.

If the string is of the CHAR data type, the result is also of type CHAR.

If the string is of type VARCHAR2, then the result is also of type VARCHAR2.

Example:

SELECT LOWER ('AaBbCcDd') "AaBbCcDd"

FROM DUAL

INITCAP syntax: INITCAP (string) description: string that returns the first letter of each word in a string in uppercase and the other letters in the word in lowercase. The word is used. Spaces or separation of alphanumeric characters. Characters that are not letters do not change. Example:

SELECT INITCAP ('ryan') UPP

FROM DUAL

Character processing function

Function description CONCAT syntax: CONCAT (string1,string2) description: returns string1 and connects string2 later. Example:

SELECT CONCAT ('010 phone call 8888888888) | |' transfer to 23' phone number

FROM DUAL

SUBSTR syntax: SUBSTR (string,a [, b]) description: returns a substring of string that starts with the value an and is b characters long. If an is 0, then it is considered to start with the first character. If it is a positive number, the return character is calculated from left to right. If b is negative, the returned characters are calculated from right to left starting at the end of string. If b does not exist, it defaults to the entire string. If b is less than 1, then NULL. If an or b uses a floating-point number, the value will first be an integer before processing. Example:

SELECT SUBSTR ('1308888888888)

FROM DUAL

LENGTH syntax: LENGTH (string) description: returns the length of the byte unit of string. Char values are filled with blanks. If string is of the data type CHAR, its trailing spaces are calculated to the middle of the string length. If string is NULL, the return result is NULL, not 0. 0. Example:

SELECT length ('Ryan') FROM DUAL

INSTR syntax: INSTR (string1, string2, [string1 b]) description: get the location of the string2 in the string1. String1 starts from the left and starts at a. If an is a negative, then string1 starts scanning from the right. The location of the b th occurrence will be returned. Both an and b are set to 1 by default, which returns the location where string2 first appeared in string1. If string2 is not found under an and b, 0. 0 is returned. The position is calculated relative to the start position of the string1, regardless of the values of an and b. Example:

SELECT INSTR ('oracle traning','ra',1,2) instring

FROM DUAL

LPAD | RPAD syntax: LPAD (string1,x [, string2]), RPAD (string1,x [, string2]) description: returns the string1 that inserts a character in string2 at the length of the X character. If the length of the string2 is less than the X character, copy it as needed and fill it left | right. If the string2 is more than X characters, only the X characters preceding the string1 are used. If no string2 is specified, fill left / right with spaces. X is used to show that the length can be longer than the actual length of the string. Example:

SELECT RPAD ('Ryan',10,'*'), LPAD (' Ryan',10,'*')

FROM DUAL

TRIM syntax: TRIM ([[LEADING | | TRAILING | | BOTH] c2 FROM] C1) description:

If no parameters are specified, oracle removes C1 header and trailing spaces

If the parameter is specified, the C1 header c2 will be removed

If the leading parameter is specified, C1 header c2 will be removed

If the trailing parameter is specified, C1 tail c2 will be removed.

Example:

Example 1:

SELECT TRIM ('What is tHis')

FROM DUAL

Example 2:

SELECT TRIM ('W'FROM' What is tHis w W')

FROM DUAL

Example 3:

SELECT TRIM (LEADING 'W'FROM' What is tHis w W')

FROM DUAL

Example 4:

SELECT TRIM (TRAILING 'W'FROM' What is tHis w W')

FROM DUAL

REPLACE syntax: REPLACE (string,search_str [, replace_str]) states: replace all substring search_str in string with optional replace_str. If no replace_str is specified, all substring search_str in string will be deleted. REPLACE is a subset of the functionality provided by TRANSLATE. Example:

SELECT REPLACE ('He love you','He','I')

FROM DUAL

Third, numeric function description ROUND syntax: ROUND (x [, y]) description: returns the X value rounded to the right of the decimal point. Y defaults to 0, which rounds X to the nearest integer. If Y is negative, it must be rounded to the left of the decimal point, and Y must be an integer. Example:

SELECT ROUND (55.5), ROUND (- 55.4)

FROM DUAL

TRUNC syntax: TRUNC (x [, y]) states that the value function is truncated, and Y defaults to 0, so that X is truncated to an integer. If Y is negative, intercept to the left of the decimal point.

SELECT TRUNC (124.166), TRUNC (124.1666)

FROM DUAL

MOD syntax: MOD (divisor, divisor) description: the remainder function, if the divisor is 0, the divisor is returned. Example:

SELECT MOD (10par 3)

MOD (3pr 3)

MOD (2pr 3)

FROM DUAL

Fourth, date function description SYSDATE syntax: SYSDATE description: returns the current date and time. Example:

SELECT SYSDATE FROM DUAL

MONTHS_BETWEEN syntax: MONTHS_BETWEEN (fjore s) description: returns an example of the month over a period of two days:

SELECT MONTHS_BETWEEN (SYSDATE,TO_DATE ('2017-11-12))

FROM DUAL

ADD_MONTHS syntax: ADD_MONTHS (dQuery n) description: returns a new date example sentence that adds the number of months to the date:

SELECT ADD_MONTHS (SYSDATE,2)

FROM DUAL

NEXT_DAY syntax: NEXT_DAY (d, day_of_week) description: returns the date of the first working day named by "day_of_week" after the date specified by the variable "d". The parameter "day_of_week" must be a day of the week. Example:

SELECT NEXT_DAY (SYSDATE,1)

FROM DUAL

LAST_DAY syntax: LAST_DAY (date) description: last day of this month example sentence:

SELECT LAST_DAY (SYSDATE)

FROM DUAL

ROUND syntax: ROUND (date, [fmt]) description: round the date in the specified format. Example sentence:

SELECT ROUND (SYSDATE,'YEAR')

FROM DUAL

TRUNC syntax: TRUNC (date, [fmt]) description: returns the DATE after the intercept time part. If there is a setting for the fmt part, return the example sentence of the date closest to this part:

SELECT TRUNC (SYSDATE,'YEAR')

FROM DUAL

At this point, I believe you have a deeper understanding of the "C++ character function, number function and date function description". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report