Chin
Chin

Reputation: 12712

Storing numbers to MySQL

Excuse ,please could someone possibly tell me what are the best column types for the following numbers?

0.021,-0.001

Upvotes: 3

Views: 973

Answers (4)

vbence
vbence

Reputation: 20333

It depends. You can use flotaing point values like DOUBLE if it's alright not to have exact values.

If your values are between 0 and 1 and 4 digits long, you can also use DECIMAL(1, 3) for example.

Upvotes: 1

David
David

Reputation: 218828

Depends on what those values mean in the system. If I were to guess, I'd say you're looking for a fixed-point type, such as Decimal. You have several options with numeric data types, though.

Upvotes: 1

Eugene Yarmash
Eugene Yarmash

Reputation: 149756

If you need exact precision (e.g. when storing financial figures), use DECIMAL. Otherwise FLOAT should do.

Upvotes: 7

dting
dting

Reputation: 39287

http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html

You should look over that reference. You weren't specific enough in your question to give a definitive answer, but it looks like, float or decimal types would work for you.

Upvotes: 1

Related Questions