Why Android Android developer can store double value (java 8 bytes) in float column

Create Table:
db.execSQL("CREATE TABLE " + PERSONS_TABLE + " ("
        + PersonsColumns.ID 
        + " INTEGER PRIMARY KEY AUTOINCREMENT, "
        ...
            + PersonsColumns.HEIGHT + " FLOAT, "
                    + PersonsColumns.CITY + " STRING);");
Write Data:
ContentValues values = new ContentValues();
alues.put(PersonsColumns.HEIGHT, 1.7976931348623157E308);
db.insertOrIgnore(values);

You can see that the value 1.7976931348623157E308 is outside the range of FLOAT values ​​(4 bytes) in sqlite. why can he correctly save this value?

+4
source share
4 answers

SQLite is "impersonal." You can store any data you want in any column of any table, regardless of the declared data type of this column.

SQLite also allows you to omit the data type.

+5
source

SQLite3, unlike full-fledged DBMS / RDBMS, such as Oracle, MSSQL, etc., has many limitations. Firstly, it does not support many data types.

@Ketan Patel, float, . , , Data Type .

: http://sqlite.org/datatype3.html

:

1.0

, SQLite ( ) :

NULL. NULL.

INTEGER. , 1, 2, 3, 4, 6 8 .

. , 8- IEEE.

TEXT. , (UTF-8, UTF-16BE UTF-16LE).

BLOB. , , .

+3

sqls , 4 , double - 8 . (, 4 8 ). postgresql, , float .

http://www.postgresql.org/docs/8.1/static/datatype.html#DATATYPE-FLOAT

PostgreSQL SQL float float (p) . p . PostgreSQL float (1) - float (24) , float (25) - float (53) . p . float .

sqlite.

1.0

  • . , 8- IEEE.

, REAL , REAL, DOUBLE, DOUBLE PRECISION FLOAT.

+1
source

you can try the float values ​​to convert to sting and paste and get simple, some float times don't get more values ​​so that this problem occurs.

0
source

All Articles