> From: Michael She <[EMAIL PROTECTED]> > Date: Fri, 20 Dec 2002 21:18:44 -0500 > To: Paul DuBois <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Subject: Re: MySQL Decimal Column Types Question > > At 06:17 PM 12/20/2002 -0600, Paul DuBois wrote: >> At 17:21 -0500 12/20/02, Michael She wrote: >>> Hi all, >>> >>> >>> What does a 10,2 decimal definition mean. >>> >>> Is it 10 Digits in total with 2 decimal places OR 10 integer digits with >>> 2 decimal places? >> >> The former. >> >>> >>> For a 10,2 decimal column, should this be a valid number: 1234567890.12? >> >> It's easy to test: >> >> mysql> CREATE TABLE t (d DECIMAL(10,2)); >> Query OK, 0 rows affected (0.01 sec) >> >> mysql> INSERT INTO t SET d = 1234567890.12; >> Query OK, 1 row affected (0.01 sec) >> >> mysql> SELECT * FROM t; >> +--------------+ >> | d | >> +--------------+ >> | 999999999.99 | >> +--------------+ >> 1 row in set (0.00 sec) >> >> The value's been clipped to the upper end of the range. >> >> Your next question should be why that value has 9 digits to the left >> of the decimal point. :-) > > > How did you guess! This behaviour is why I asked the question in the first > place. Why does it get clipped for a 10 digit number. Without the decimal > value I believe it inserts correctly, but with the 2 decimal places it get > clipped... > -- > Michael She : [EMAIL PROTECTED] > Mobile : (519) 589-7309 > WWW Homepage : http://www.binaryio.com/ > >
>> mysql> INSERT INTO t SET d = 1234567890.12; >> Query OK, 1 row affected (0.01 sec) A different question would be why does MySQL not generate an error or warning on the insert when it mangled the value? Also decimal(10,2) will store -12345678.90 as well. This is different behavior than many other databases. -- Jim Dickenson mailto:[EMAIL PROTECTED] Computers for Marketing Corporation http://www.cfmc.com/ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php