How to use an affinity like SQLite 3?

According to the SQLite 3 documentation, it says it has an affinity type function to force input of column data types. But how to turn it on?

+6
source share
2 answers

The affinity type does not force the column data types - it just makes an assumption about how the data store stores the data.

In the "affinity for type" section:

A column affinity type is the recommended type for storing data in this column. The important idea here is that a type is recommended, not required. Any column can store any type of data.

(in italics)

As for β€œhow to turn it on,” there is no such thing. This is how SQLite works all the time. There is nothing to turn on or off to get this functionality.

+5
source

The column data types are not executed, just suggested by their declared types in the create table statement. This is what they mean by type of affinity.

The affinity type for a column is the recommended type of data stored in this column. The important idea here is that the type recommended is not required. Any column can store any type of data. Just some columns, given the choice, would prefer to use one storage class over another. The preferred storage class for a column is called its affinity.

+2
source

Source: https://habr.com/ru/post/912669/


All Articles