zoukankan      html  css  js  c++  java
  • [转]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

  • 相关阅读:
    Mina Core 10-执行器过滤器
    Mina Core 09-编解码过滤器
    Mina Core 08-IoBuffer
    Mina Basics 07-处理程序Handler
    Mina Basics 06-传输
    Mina Basics 05-过滤器
    Mina Basics 04- 会话
    Mina Basics 03-IoService
    Mina Basics 02-基础
    Mina Basics 01- 入门
  • 原文地址:https://www.cnblogs.com/z5337/p/6490239.html
Copyright © 2011-2022 走看看