热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

SQLite核心函数一览

abs(X)abs(X)返回X的绝对值。Abs(X)returnsNULLifXisNULL.Abs(X)return0.0ifXisastringorblobt

abs(X)

abs(X)返回 X 的绝对值。

Abs(X) returns NULL if X is NULL.

Abs(X) return 0.0  if X is a string or blob that cannot be converted to a numeric value. If X is  the integer -9223372036854775807 then abs(X) throws an integer overflow error  since there is no equivalent positive 64-bit two complement value.

changes()

changes()函数返回数据库已更新的记录数INSERT, DELETE, UPDATE 语句。

char(X1,X2,...,XN) 返回X1,X2,...,XN等UNICODE码对应的字符。
coalesce(X,Y,...)

返回第一个非空参数,全为NULL时返回NULL;参数至少包含两个参数。

glob(X,Y) 用于实现SQLite的 "X GLOB Y"语法。可使用 sqlite3_create_function() 重载该函数从而改变GLOB运算符的功能。
ifnull(X,Y) 返回第一个非空参数的副本。 若两个参数均为NULL,返回NULL。与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 are 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 are not BLOBs then both are  interpreted as strings. If either X or Y are 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 of 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 invoked the  function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid()  C/C++ interface function.
length(X) For a string value X, the length(X) function returns  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 the total 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)

用于实现SQL语法"X LIKE Y [ESCAPE Z]".若使用可选的ESCAPE子句,则函数被赋予三个参数,否则只有两个。可使用sqlite3_create_function() 重载该函数从而改变LIKE运算符的功能。 注意同时重载like()的两参数和三参数版本,否则在使用/不使用 ESCAPE子句时,LIKE运算符的实现可能使用的是不同的代码。

likelihood(X,Y) The likelihood(X,Y) function returns argument X  unchanged. The value Y in likelihood(X,Y) must be a floating point constant  between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that  the code generator optimizes away so that it consumes no CPU cycles during  run-time (that is, 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 that 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)
尝试加载一个SQLite扩展库
lower(X) 转换为小写
ltrim(X)
 ltrim(X,Y)
The ltrim(X,Y) function returns a string formed by  removing any and all characters that 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,...) 返回一组中的最大值。
min(X,Y,...) 返回一组中的最小值。
nullif(X,Y) 当两参数不同时返回X,否则返回NULL。
quote(X) 返回参数的适于插入其它SQL语句中的值。字符串会被添加单引号,在内部的引号前会加入逃逸符号。 BLOB被编码为十六进制文本。当前的VACUUM使用这一函数实现。在使用触发器实现撤销/重做功能时这一函数也很有用。
random() 返回一个[-9223372036854775808,+9223372036854775807]区间内的随机数
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 random blob  is returned. Hint: applications can generate globally unique  identifiers using this function together with hex()and/or lower() 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 an empty string then  return X unchanged. If Z is not initially a string, it is cast to a UTF-8  string prior to processing.
round(X)
 round(X,Y)
X四舍五入,保留小数点后Y位。若忽略Y参数,则默认其为0。
rtrim(X)
 rtrim(X,Y)

rtrim(X,Y) 返回去除X串右边的Y字符的副本。

rtrim(X) 返回去除X串右边的空格字符的副本。

soundex(X) The soundex(X) function returns a string that is the  soundex encoding of the string X. The string "?000" is returned if  the argument is NULL or contains no ASCII alphabetic characters. This  function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX  compile-time option is used when SQLite is built.
sqlite_compileoption_get(N) The sqlite_compileoption_get() SQL function is a  wrapper around the sqlite3_compileoption_get() C/C++ function. This  routine returns the N-th compile-time option used to build SQLite or NULL if  N is 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) is a string which is the name  of a compile-time option, this routine returns true (1) or false (0)  depending on whether or not that 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 was used to  build the SQLite library. The string returned by sqlite_source_id() begins  with the date and time that the source code was checked in and is follows by  an SHA1 hash that uniquely identifies the source tree. This function is an  SQL wrapper around thesqlite3_sourceid() C interface.
sqlite_version() 返回SQLite数据库版本信息
substr(X,Y,Z)
 substr(X,Y)
返回输入字符串X中以第Y个字符开始,Z个字符长的子串。 X最左端的字符序号为1。若Y为负,则从右至左数起。若SQLite配置支持UTF-8,则“字符”代表的是UTF-8字符而非字节。
total_changes() The total_changes() function returns the number of  row changes caused by INSERT, UPDATE or DELETE statements since the current  database connection was opened. This function is a wrapper around the sqlite3_total_changes()  C/C++ interface.
trim(X)
 trim(X,Y)
The trim(X,Y) function returns a string formed by  removing any and all characters that appear in Y from both ends of X. If the  Y argument is omitted, trim(X) removes spaces from both ends of X.
typeof(X) 返回表达式X的类型。返回值可能为"null", "integer", "real", "text", 以及 "blob".
unlikely(X) The unlikely(X) function returns the argument X  unchanged. The unlikely(X) function is a no-op that the code generator optimizes  away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()).  The purpose of the unlikely(X) function is to provide a hint to the query  planner that the argument X is a boolean value that is 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) is not a string then the result is undefined.
upper(X) 转换为大写
zeroblob(N) The zeroblob(N) function returns a BLOB consisting  of N bytes of 0x00. SQLite manages these zeroblobs very efficiently.  Zeroblobs can be used to reserve space for a BLOB that is later written using  incremental  BLOB I/O. This SQL function is implemented using the sqlite3_result_zeroblob()  routine from the C/C++ interface.

推荐阅读
  • 部分转载自:http:blog.csdn.netliujiuxiaoshitouarticledetails69920917头文件#include<assert.h& ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • 在Oracle11g以前版本中的的DataGuard物理备用数据库,可以以只读的方式打开数据库,但此时MediaRecovery利用日志进行数据同步的过 ... [详细]
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
  • SQL Server 2008 到底需要使用哪些端口?
    SQLServer2008到底需要使用哪些端口?-下面就来介绍下SQLServer2008中使用的端口有哪些:  首先,最常用最常见的就是1433端口。这个是数据库引擎的端口,如果 ... [详细]
  • 折腾个半死,数据库初始化设置不当报错 ORA01078: failure in proces...
    2019独角兽企业重金招聘Python工程师标准[oraclelocalhost~]$sqlplusassysdba提示Connectedtoanidleinstance.连 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
author-avatar
有心人php
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有