On 19 Mar 2013, at 11:51am, Philipp Kursawe <[email protected]> wrote:

> CREATE TABLE test (dt BIG INT)

Note that SQLite does not have a BIG INT type.  The text you show there will 
result in a column with INTEGER affinity.

> and inserted a value:
> INSERT INTO test VALUES(CURRENT_TIMESTAMP)
> 
> This goes through without an error and the physical db file then really
> contains the current timestamp as a string. How can that be? Is the column
> internally converted on the fly?

SQLite does not have strict typing for values stored in tables.  It uses 
'affinities' instead which are more a preference than a 'strict' thing.  If you 
are specific about saying you want a CURRENT_TIMESTAMP then that's what it will 
store, and that is a string.  You can read about affinities in section 2 of 
this page:

<http://www.sqlite.org/datatype3.html>

You can generate CURRENT_TIMESTAMP as an integer using the datetime functions:

<http://www.sqlite.org/lang_datefunc.html>

In your case, guessing that you want an integer which represents the current 
time to at least 1 second of precision, I would suggest you use

INSERT INTO test VALUES(strftime('%s','now'))

I have not tried the above code, so please don't take what I wrote as 
definitely what you want, or even definitely working.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to