PDA

View Full Version : How store a unsigned short into a database



franco.amato
17th January 2011, 16:11
Hi to all,
I would store a unsigned short type ( 98 elements of ushort ) into a database ( ms sql express 2005 and sqlite ). But I can not find the correct type.
I would have some help.
Best Regards,
Franco

wysota
17th January 2011, 20:08
You cannot find a correct type for what?

franco.amato
17th January 2011, 20:18
You cannot find a correct type for what?

Wysota hi,
I can not find a correct type in the database that can store a ushort.
Regards

wysota
17th January 2011, 21:01
For SQLite it doesn't matter as it will store it as text anyway. For other databases it will be something like SMALLINT or INTEGER(maximum_number_of_digits). If I understand correctly that you need an array of those then I think you need to rethink your design -- databases don't like arrays. You can store it as text separated by commas -- it will be as inefficient as any other kind of representation.

ChrisW67
17th January 2011, 22:17
For SQLite it doesn't matter as it will store it as text anyway.
This is true of Sqlite2 but not Sqlite3, which uses a variable length binary representation of integer data in columns with numeric affinity (if possible).
http://sqlite.org/datatype3.html