SQLite core functions at a glance

Source: Internet
Author: User
Tags abs generator glob numeric value rtrim sha1 hash sqlite sqlite database

ABS (X)

ABS (x) returns the absolute value of x.

Abs (x) returns null if X is null.

Abs (x) return 0.0 if X is a string or blob of that cannot being converted to a numeric value. If X is the integer-9223372036854775807 then abs (X) throws a integer overflow error since there is no equivalent posit Ive 64-bit and complement value.

Changes ()

The changes () function returns the number of records that have been updated in the database insert, DELETE, UPDATE statement.

char (x1,x2,..., XN) Returns the characters that correspond to Unicode codes such as X1,x2,..., xn.
COALESCE (x, y,...)

Returns NULL when the first non-null argument is returned, all NULL when the parameter contains at least two arguments.

Glob (x, y) Used to implement the "X GLOB Y" syntax for SQLite. You can use Sqlite3_create_function () to overload the function to change the function of the glob operator.
Ifnull (x, y) Returns a copy of the first non-null parameter. If all two parameters are NULL, NULL is returned. Similar to coalesce ().
InStr (x, Y) The InStr (x, Y) function finds the first occurrence of string Y within string X and returns the number of prior characters Plus 1, or 0 if Y is nowhere found within X. Or, if X and Y is both BLOBs, then InStr (x, Y) returns one more than the number bytes prior to the first occurrence of Y , or 0 if Y does not occur anywhere within X. If both arguments X and Y to InStr (x, y) are non-null and is not BLOBs then both is interpreted as strings. If either X or Y is null in InStr (x, y) Then the result is null.
Hex (X) The hex () function interprets its argument as a BLOB and returns a string which is the upper-case hexadecimal rendering O f The content of that blob.
Last_insert_rowid () The Last_insert_rowid () function returns the rowid of the last row insert from the database connection which INV OKed the function. The Last_insert_rowid () SQL function is a wrapper around the Sqlite3_last_insert_rowid () C + + interface Functio N.
length (x) for a String value X, the length (x) function R Eturns  the number of characters (not bytes) in X prior to the first NUL character. Since  sqlite strings do not normally contain NUL characters, the length (X) function  will usually return Tal number of characters in the string x. For a  blob value X, Length (X) Returns the number of bytes in the blob. If X is null  then length (X) is null. If x is numeric then length (X) returns the length of  a string representation of X.
like (x, y)
 like (x, Y, z)

for sql syntax "X like Y [ESCAPE Z]". If an optional escape clause is used, the function is given three parameters, otherwise there are only two. You can use sqlite3_create_function ()   Reload this function to change the functionality of the like operator.   Note overload like () for both and three-parameter versions, otherwise when using /do not use  escape clauses , the implementation of the like operator may be using different code.

Likelihood (x, y) The likelihood (x, Y) function returns argument X unchanged. The value Y in likelihood (x, y) must is a floating point constant between 0.0 and 1.0, inclusive. The likelihood (X) function is a no-op, the code generator optimizes away so it consumes no CPU cycles during RU N-time (that's, during calls to Sqlite3_step ()). The purpose of the likelihood (x, y) function is to provide a hint to the query planner that the argument X is a Boolean t  Hat is true with a probability of approximately Y. The unlikely (X) function is short-hand for likelihood (x,0.0625).
Load_extension (X)
Load_extension (x, y)
Try to load a sqlite extension library
Lower (X) Convert to lowercase
LTrim (X)
LTrim (x, y)
The LTrim (x, y) function returns a string formed by removing any and all characters this appear in Y from the left side of X. If the Y argument is omitted, LTrim (x) removes spaces from the left side of X.
Max (x, y,...) Returns the maximum value in a group.
Min (x, y,...) Returns the minimum value in a group.
Nullif (x, y) Returns NULL if both parameters do not return X at the same time .
QUOTE (X) Returns the value of the parameter that is appropriate for inserting other SQL statements. The string is added as a single quotation mark, and the escape symbol is added before the inner quotation marks. blobs are encoded as hexadecimal text. The current vacuum is implemented using this function. This function is also useful when using triggers to implement undo /Redo functionality.
Random () Returns a random number within a [ -9223372036854775808,+9223372036854775807] interval
Randomblob (N) The Randomblob (N) function return an n-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte the random blob is returned. Hint:applications can generate globally unique identifiers using this function together with hex ()and/or lo Wer () like This:hex (Randomblob (16))

Lower (Hex (Randomblob (16)))
Replace (x, Y, z) The replace (x, y, z) function returns a string formed by substituting string Z for every occurrence of string Y in string X . TheBINARY collating sequence is used for comparisons. If Y is a empty string then return X unchanged. If Z is not initially a string, it's cast to a UTF-8 string prior to processing.
Round (X)
Round (x, y)
Rounds X, leaving the Y-bit after the decimal point . If you omit the y parameter, it defaults to 0.
RTrim (X)
RTrim (x, y)

RTrim (x, y) returns a copy of the Y character that is removed to the right of the X string.

RTRIM (x) returns a copy of the space character that is removed to the right of the X string.

Soundex (X) The SOUNDEX (X) function returns a string that is the SOUNDEX encoding of the string x. The string "?" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function was omitted from SQLite by default. It is only available if the sqlite_soundex compile-time option was used when SQLITE is built.
Sqlite_compileoption_get (N) The Sqlite_compileoption_get () SQL function is a wrapper around the Sqlite3_compileoption_get () C + + function. This routine returns the n-th, compile-time option used to build SQLite or NULL if N are out of range. See also thecompile_options pragma.
sqlite_compileoption_used (X) the sqlite_ compileoption_used () SQL function is a  wrapper around The sqlite3_compileoption_used ()  c/c++ function. When  the argument X to Sqlite_compileoption_used (x) was a string which is the name  of a compile-time option, th Is routine returns True (1) or False (0)  depending on whether, or not, option was used during the build.
SQLITE_SOURCE_ID () The sqlite_source_id () function returns a string that identifies the specific version of the source code that is used to Build the SQLite library. The string returned by sqlite_source_id () begins with the date and time, the source code was checked on and is follow s by a SHA1 hash that uniquely identifies the source tree. This function was an SQL wrapper around theSqlite3_sourceid () C interface.
Sqlite_version () Back to SQLite database version information
substr (x, Y, z)
substr (x, y)
Returns a substring that starts with the nth character in the input string x and is Z characters long . The left-most character ordinal of x is 1. If y is negative, the number is from right to left. If the sqlite configuration supports UTF-8, then "character " represents the UTF-8 character rather than the byte.
Total_changes () The Total_changes () function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the CU Rrent database connection was opened. This function is a wrapper around the sqlite3_total_changes () C + + interface.
Trim (X)
Trim (x, y)
The trim (x, y) function returns a string formed by removing an and all characters this appear in Y from both ends of X. I f The Y argument is omitted, trim (x) removes spaces from both ends of X.
typeof (X) Returns the type of an expression X. The return value may be "null", "integer", "real", "text", and "blob".
Unlikely (X) The unlikely (x) function returns the argument x unchanged. The unlikely (X) function is a no-op, the code generator optimizes away so, it consumes no CPU cycles at Run-time  (That's, during calls to Sqlite3_step ()). The purpose of the unlikely (X) function is to provide a hint to the Query planner this argument X is a Boolean value That's usually not true. The unlikely (x) function is equivalent to likelihood(x, 0.0625).
Unicode (X) The Unicode (X) function returns the numeric Unicode code point corresponding to the first character of the string X. If the argument to Unicode (X) are not a string then the result is undefined.
Upper (X) Convert to uppercase
Zeroblob (N) The Zeroblob (N) function returns a BLOB consisting of N bytes of 0x00.  SQLite manages these zeroblobs very efficiently. Zeroblobs can used to reserve space for a blob, which is later written using incremental blob I/O. This SQL function is implemented using the -Sqlite3_result_zeroblob () routine from the C + + interface.

SQLite core functions at a glance

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.