随笔 - 750  文章 - 1  评论 - 107  阅读 - 34万

[转]SQLite 经验集

SQLite 的默认时间 转自:http://www.cnblogs.com/pennant/archive/2011/08/11/2134897.html

select strftime('%Y-%m-%d %H:%M:%S','now')

这个查询的结果是 UTC时间,即 +8h 才和电脑时间相同。

select time('now')

这个查询的结果是 01:02:03 ,也要 +8h 才和电脑时间相同。

select date('now')

这个查询的结果是 2017-03-02

select datetime('now')

这个查询的结果是 2017-03-02 01:02:03 

复制代码
  %d 一月中的第几天01-31

  %f 小数形式的秒,SS.SSSS

  %H 小时00-24

  %j 一年中的第几天01-366

  %J Julian Day Numbers

  %m 月份01-12

  %M 分钟00-59

  %s 从1970-01-01日开始计算的秒数

  %S 秒00-59

  %w 星期,0-6,0是星期天

  %W 一年中的第几周00-53

  %Y 年份0000-9999

  %% %百分号
复制代码

SQLite: Data Types - 数据类型

The following is a list of datatypes available in SQLite, which includes string, numeric, date/time, and large object datatypes.

For simplicity's sake, SQLite essentially uses these basic datatypes:

  • TEXT
  • INTEGER
  • NUMERIC
  • REAL
  • NONE

To be compatible with other SQL databases, SQLite allows you to use the common datatype names that you've seen in other databases and maps them to their basic SQLite datatypes (listed above).

Let's look at the common datatypes names that SQLite lets you define.

String Datatypes

All string datatypes in SQLite are converted to a TEXT datatype. If you try to specify a size for a string datatype, SQLite will ignore it, as it does not allow size restrictions on string datatypes.

The following are the String Datatypes in SQLite:

Data Type SyntaxExplanation
CHAR(size) Equivalent to TEXT (size is ignored)
VARCHAR(size) Equivalent to TEXT (size is ignored)
TINYTEXT(size) Equivalent to TEXT (size is ignored)
TEXT(size) Equivalent to TEXT (size is ignored)
MEDIUMTEXT(size) Equivalent to TEXT (size is ignored)
LONGTEXT(size) Equivalent to TEXT (size is ignored)
NCHAR(size) Equivalent to TEXT (size is ignored)
NVARCHAR(size) Equivalent to TEXT (size is ignored)
CLOB(size) Equivalent to TEXT (size is ignored)

Numeric Datatypes

All numeric datatypes in SQLite are converted to INTEGER, NUMERIC, or REAL datatypes.

The following are the Numeric Datatypes in SQLite:

Data Type SyntaxExplanation
TINYINT Equivalent to INTEGER
SMALLINT Equivalent to INTEGER
MEDIUMINT Equivalent to INTEGER
INT Equivalent to INTEGER
INTEGER Equivalent to INTEGER
BIGINT Equivalent to INTEGER
INT2 Equivalent to INTEGER
INT4 Equivalent to INTEGER
INT8 Equivalent to INTEGER
NUMERIC Equivalent to NUMERIC
DECIMAL Equivalent to NUMERIC
REAL Equivalent to REAL
DOUBLE Equivalent to REAL
DOUBLE PRECISION Equivalent to REAL
FLOAT Equivalent to REAL
BOOLEAN Equivalent to NUMERIC

Date/Time Datatypes

All date or time datatypes in SQLite are converted to NUMERIC datatypes.

The following are the Date/Time Datatypes in SQLite:

Data Type SyntaxExplanation
DATE Equivalent to NUMERIC
DATETIME Equivalent to NUMERIC
TIMESTAMP Equivalent to NUMERIC
TIME Equivalent to NUMERIC

Large Object (LOB) Datatypes

The following are the LOB Datatypes in SQLite:

Data Type SyntaxExplanation
BLOB Equivalent to NONE

posted on   z5337  阅读(140)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2015-03-02 VBA Excel 对比两列数据
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示