SQLite 3 system in IOS applications

Source: Internet
Author: User

IOS appAboutSQLite3. the type system is the content to be introduced in this article, mainly for understanding and learning.IOS appMediumSQLiteAboutSQLiteInIOS appOperation in this article has a very detailed explanation, see the content.

InIOS appThe client stores data in SQLite3. The following describes the data types supported by SQLite and the relationships between the types. Most databases use static strict type systems. The column type is specified when creating a table. SQLite uses a dynamic type system. The column type is determined by the value.

SQLite Data Types

 
 
  1. NULL:NULLvalue 

Integer: The value belongs to the signedinteger type. The value can be 1, 2, 3, 4, 6, or 8 bytes.

REAL: floating point type

TEXT: character type stored in UTF-8, UTF-16BEorUTF-16LE Encoding

BLOB: binary data

Other data types

The Integerprimarykey column is an exception ??

Boolean Type: SQLite does not define the boolean type, but stores boolean values by Integer, 0 (false), 1 (true)

Dateandtime type

SQLiteThe date and time types are not defined. The date and time can be stored in TEXT, REAL, or orINTEGER.

TEXT: stored as a string ("YYYY-MM-DDHH: MM: SS. SSS ").

 
 
  1. REAL:asJuliandaynumbers,thenumberofdayssincenooninGreenwichonNovember24,4714B.C.accordingtotheprolepticGregoriancalendar.  
  2.  
  3. INTEGER:asUnixTime,thenumberofsecondssince1970-01-0100:00:00UTC. 

SQLiteTypeAffinity type detection)

The type of the value used for automatic detection. The following lists how Affinity determines the type rules.

1) if the type declaration contains int, use INTEGERaffinity.

2) If the type declaration contains "CHAR", "CLOB", or "TEXT", use Textaffinity

3) if the type declaration contains BLOB or the type is not specified, use affinityNONE

4) if the type declaration contains "REAL", "FLOA", or "DOUB", use REALaffinity

5) Otherwise, use Numericaffinity.

Type comparison NULL

Memcmp function prototype

 
 
  1. intmemcmp(constvoid*ptr1,constvoid*ptr2,size_tnum); 

Compares the two pointers to the first num bytes in the memory.

Type conversion before comparison

L (INTEGER, REALorNUMERIC) and (TEXTorNONE), the TEXT and NONE will be converted to NUMERIC

When lTEXT and NONE are compared, NONE is converted to TEXT

Compare other cases directly.

Summary:IOS appAboutSQLite3. The content of the system type is introduced.IOS appMediumSQLiteThe learning of the Operation content is helpful to you.

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.