Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

These are the native SQLite datatypes, that are also used as column affinities.

TEXT - text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).

BLOB - blob of data, stored exactly as it was input.

NUMERIC - generic number, attempts to devolve to integer or real.

INTEGER - signed, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

REAL - floating point value, stored as an 8-byte IEEE-754 format.

Any CHAR variant is really text. If you really need it to be 50 characters, then a suitable CHECK constraint must be in place.

You can also create tables with unknown types:

CREATE TABLE foo(bar razzamataz);

With some gymnastics, you can see the affinity assigned to this column:

create table bar as select * from foo where 1=0;

  sqlite> .dump bar
  PRAGMA foreign_keys=OFF;
  BEGIN TRANSACTION;
  CREATE TABLE bar(
    bar NUM
  );
  COMMIT;


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: