Posts

Showing posts with the label Sqldatatypes

Best Data Type For Storing Currency Values In A MySQL Database

Answer : Something like Decimal(19,4) usually works pretty well in most cases. You can adjust the scale and precision to fit the needs of the numbers you need to store. Even in SQL Server, I tend not to use " money " as it's non-standard. The only thing you have to watch out for is if you migrate from one database to another you may find that DECIMAL(19,4) and DECIMAL(19,4) mean different things ( http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-changes.html ) DBASE: 10,5 (10 integer, 5 decimal) MYSQL: 15,5 (15 digits, 10 integer (15-5), 5 decimal) Assaf's response of Depends on how much money you got... sounds flippant, but actually it's pertinant. Only today we had an issue where a record failed to be inserted into our Rate table, because one of the columns (GrossRate) is set to Decimal (11,4), and our Product department just got a contract for rooms in some amazing resort in Bora Bora, that sell for several million Pacif...

Boolean Field In Oracle

Answer : I found this link useful. Here is the paragraph highlighting some of the pros/cons of each approach. The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions. Basically they advocate method number 2, for efficiency's sake, using values of 0/1 (because of interoperability with JDBC's getBoolean() etc.) with a check constraint a type of CHAR (because it uses less space than NUMBER). Their example: create table tbool (bool char check (bool in (0,1)); insert into tbool values(0); insert into tbool values(1);` Oracle itself uses Y/N for Boolean values. For completeness it should be noted th...