SQLite所支援的資料類型

來源:互聯網
上載者:User

上次工作需要學了一個月的mysql,不久知道好多東西都忘掉了,現在由於工作需要再學點sqlite,其實都差不多,Sqlite3支援的資料類型

NULL,INTEGER,REAL,TEXT,BLOB

以及:
smallint 16 位元的整數。
interger 32 位元的整數。
decimal(p,s) p 精確值和 s 大小的十進位整數,精確值p是指全部有幾個數(digits)大小值,s是指小數點後有幾位元。如果沒有特別指定,則系統會設為 p=5; s=0 。
float   32位元的實數。
double   64位元的實數。
char(n)   n 長度的字串,n不能超過 254。
varchar(n) 長度不固定且其最大長度為 n 的字串,n不能超過 4000。
graphic(n) 和 char(n) 一樣,不過其單位是兩個字元 double-bytes, n不能超過127。這個形態是為了支援兩個字元長度的字型,例如中文字。
vargraphic(n) 可變長度且其最大長度為 n 的雙字元字串,n不能超過 2000
date   包含了 年份、月份、日期。
time   包含了 小時、分鐘、秒。

timestamp 包含了 年、月、日、時、分、秒、千分之一秒。

表1-1

type description
TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, BYTEA String types of unlimited length. Binary data must be safely encoded, see text.
CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT String types of unlimited length. There is no chopping or padding performed by the database engine.
ENUM String type of unlimited length. In contrast to MySQL, choosing ENUM over VARCHAR does not save any storage space.
SET String type of unlimited length. In contrast to MySQL, the input is not checked against the list of allowed values.
YEAR String type of unlimited length. MySQL stores 2 or 4 digit years as a 1 byte value, whereas the SQLite drivers stores the string as provided.
TINYINT, INT1, CHAR A 1 byte type used to store one character, a signed integer between -128 and 127, or an unsigned integer between 0 and 255.
SMALLINT, INT2 2 byte (short) integer type used to store a signed integer between -32768 and 32767 or an unsigned integer between 0 and 65535.
MEDIUMINT 3 byte integer type used to store a signed integer between -8388608 and 8388607 or an unsigned integer between 0 and 16777215.
INT, INTEGER, INT4 4 byte (long) integer type used to store a signed integer between -2147483648 and 2147483647 or an unsigned integer between 0 and 4294967295.
BIGINT, INT8, INTEGER PRIMARY KEY 8 byte (long long) integer type used to store a signed integer between -9223372036854775808 and 9223372036854775807 or an unsigned integer between 0 and 18446744073709551615. See below for a discussion of INTEGER PRIMARY KEY.
DECIMAL, NUMERIC A string type of unlimited length used to store floating-point numbers of arbitrary precision.
TIMESTAMP, DATETIME A string type of unlimited length used to store date/time combinations. The required format is 'YYYY-MM-DD HH:MM:SS', anything following this pattern is ignored.
DATE A string type of unlimited length used to store a date. The required format is 'YYYY-MM-DD', anything following this pattern is ignored.
TIME A string type of unlimited length used to store a time. The required format is 'HH:MM:SS', anything following this pattern is ignored.
FLOAT, FLOAT4, REAL A 4 byte floating-point number. The range is -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. Please note that MySQL treats REAL as an 8 byte instead of a 4 byte float like PostgreSQL.
DOUBLE, DOUBLE PRECISION, FLOAT8 An 8 byte floating-point number. The range is -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.