Tags: f11 parameter Data number index STR SQL BCD substringLEN (): Calculates the length of the string (the number of characters). )Datalength ();//computes the number of bytes that the string occupies, not the string function.Test the difference between a varchar variable and a nvarchar variable that stores
Single-record functions in SQL1. ASCIIReturns the decimal number corresponding to the specified character;SQL> select ASCII ('A') A, ASCII ('A') A, ASCII ('0') zero, ASCII ('') space from dual;
A A zero space------------------------------------65 97 48 32
2. CHRReturns the corresponding characters;SQL> select CHR (54740) Zhao, CHR (65) chr65 from dual;
Zh C---Zha
Common commands and functions of Oracle SQL * plus, oracleplus
Common commands and functions in Oracle are sorted out for future use for convenient reference.Common commands:
Connect to sqlplusRun cmd in the command line to enter. For example, to log on in sys mode, the comm
the X field type SQL>SelectMax (distinct Sal), Max (XM) fromTable3; Max (distinctsal) max (XM)---------------- --------5555.55zhumin ([Distinct|all]x) The maximum value of the row x column is selected in the function statistics table. The "parameter" all means the maximum value for all values, distinct only the maximum value for the different values, the default is all if there is a parameter distinct or all, a space is separated from the X (column).
Tags: io ar on Data code as SQL Res harString functions are used to perform various operations on characters and binary strings, and most string functions can only be used for char, nchar, varchar, and nvarchar data types. String functio
INSTR (C1,c2[,i[,j])function searches for a specified character in a string, returning the location of the specified character;"description" multibyte character (kanji, full-width, etc.), calculated as 1 characters"Parameters" C1 the string being searched forC2 the string you want to searchI Search start position, default is 1J-J-Occurrence position, default 1"Re
and is case-sensitive only if at least one parameter is a binary string. POSITION (substr in str)Returns the position of the substring substr the first occurrence in the string str. If the substring substr does not exist in STR, the return value is 0:
The code is as follows
Copy Code
mysql> SELECT POSITION (' Bar ', ' Foobarbar ');4mysql> SELECT POSITION (' Xbar ', ' fo
Tag:substringasc-- intercept upper ring length sqlhighlight The/*len (string) function lower (string) function upper (string) function LTrim (string) function RTrim (string) function substring (string,start_position, Length) funct
Label:SQL Create function Database name--programmability---table-valued functions Right-click to create a "multi-statement table-valued Function" CREATE FUNCTION [dbo].[Fun_splitstr](@str VARCHAR(MAX))
RETURNS @temp TABLE(IDINT)
as
BEGIN
DECLARE @ch as VARCHAR( -)
SET @str+=','
while(@str"')
BEGIN
SET @ch = Left(@str,CHARINDEX(',',@str,1)-1)
IF @ch>0
INSERT @temp VALUES(@ch)
SET @str=STUFF(@str,1,CHA
follows:--CONVERT (/*"0", convert also provides a rich style for date conversion, cast only for normal date conversion"1", Data_type is the data type defined for the SQL Server system, and the user-defined data type cannot be used here.2, length specifies the length of the data, and the default value is 30.*/--★ Instance ★Select CAST (123 as nvarchar)--return 123Select N ' Age: ' +cast (nvarchar)--return Age: 23--╔══════════╗--=======================
Tags: SQL Oracle server DB2 time functionSQL Server Time article: *************************************************************One, Time function--getdate Get current timeSelect GETDATE ()--dateadd Original time Add: 2013-02-17 13:20:16 this time plus 12 monthsSelect DATEADD (month,12, ' 2013-02-17 13:20:16 ')--return: 2014-02-17 13:20:16.000 (parameter MONTH can be changed to day,year etc. date plus corres
SQL string analyzer Functions
-- ===================================================== ====== -- Create function fun_splitstr, this function converts a string separated by a separator into a table -- @ strsource used to store the string to be analyzed -- @ strseprate used
--Description: Splitting a string function--SELECT * FROM dbo. Split (' a,b,c,d,e,f,g ', ', ')-- =============================================CREATE FUNCTION [dbo].[Split](@Text VARCHAR(8000) ,@Sign NVARCHAR(4000) ) RETURNS @tempTable TABLE(IDINT IDENTITY(1,1)PRIMARY KEY,[TempVal] VARCHAR(4000) ) as BEGIN DECLARE @StartIndex INT --where to start looking DECLARE @FindIndex INT --location found DECLARE @Content VARCHAR(4000)--the value foundSET
Single-record functions in SQL
1. ASCIIReturns the decimal number corresponding to the specified character;SQL> select ASCII ('A') A, ASCII ('A') A, ASCII ('0') zero, ASCII ('') space from dual;
A A zero space------------------------------------65 97 48 32
2. CHRReturns the corresponding characters;SQL> select CHR (547
1. Character functions:
The characters in SQL Server are case-insensitive.However, the lower and upper functions are common in SQL Server, Oracle, and DB2. For example, select empno, ename, deptno from EMP where upper (ename) = upper ('bucket ');
Example of connection chara
, ' SS ') from TABLE_NAME;SELECT to_char (sysdate, ' Yyyy-mm-dd hh:24:mi:ss ') from table_name;To_number () converts a valid string into a digital SELECT to_number (' 88877 ') from table_name; 88877To_char () Converts a number to a string SELECT to_char (88877) from table_name; ' 88877 ' 5. Character functionsCharacter functions are primarily used to modify char
43. Convert (C, dset, sset)Convert the source string sset from one language character set to another destination dset Character Set
SQL> select convert ('strutz', 'we8hp ', 'f7dec') "Conversion" from dual;
Conver------Strutz
44. hextorawConverts a hexadecimal string to a binary string.
45. rawtohextConverts a binary
Common commands and functions of Oracle SQL * plus, oracleplus
Common commands:
Connect to sqlplusRun cmd in the command line to enter. For example, to log on in sys mode, the command is as follows:(1). sqlplus "sys/zhb126 as sysdba"
(2). sqlplus/nolog connect sys/zhb126 as sysdba
(3). sqlplus scott/tiger
Start a database instance
Startup -- start the control fil
Differences between oracle and SQL (common functions) (4) ORACLE functions
BitsCN.com
Ual
41. a day of the week (such as Sunday)
S: unknown
O: SELECT Next_day (sysdate, 7) vaule from dual;
42. string conversion time
S: can be dire
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.