2012年3月27日星期二

Float or Int

Does it make a difference if I use the Float or Int data type for a field such as ReceiptNumber or CheckNumber?

Thanks for any thoughts,It absolutely makes a difference -- use an int. Floating-point columns are used for scientific calculations and store floating-point numbers.

And actually, depending on how those columns are being generated and what their purpose is, I feel that varchar might be a better choice. To me, numeric data types are only appropriate for primary keys and for columns where some sort of math is going to happen.

Terri|||Required more memory too..

KP|||Is there a way that I can globally change the float to int in all of the tables in a DB? and is there an example of this some where?

Thank you,|||Well, you can find out where you have used the float data type in your database by issuing this:

SELECT * FROM information_schema.columns WHERE data_type = 'float'

You could write some script that selects this information into a cursor and then you could scroll through the cursor putting together dynamic SQL statements to execute that would do an ALTER TABLE and change the data type. Whether or not this would be worth the trouble is dependent upon how many occurrences you have.

Terri|||Terri,

Thank you very much!sql

没有评论:

发表评论