Sample Exam Questions

## From the objective of OSS-DB Exam Silver - Development/SQL - SQL command (data type)

#### 3.03Choose the correct statement about PostgreSQLs data types.

1. Since INTEGER can handle integers up to 10 digits, declaring it as NUMERIC (10) is the same.
2. Since REAL can handle decimal numbers with precision of 6 digits, declaring it as NUMERIC (10, 6) is the same.
3. DOUBLE PRECISION can handle decimal numbers with a precision of 15 digits, so declaring it as NUMERIC (10, 15) is the same.
4. Since INTEGER's operation is faster than NUMERIC, if the value is always an integer, you should use INTEGER instead of NUMERIC.
5. It is not possible to expect that the result will be true when performing equivalence comparison (comparison of the form of a = b) for 0.1 of the REAL type and 0.1 of the NUMERIC type.

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2018/04/07

#### Answer and Explanation

The INTEGER type of PostgreSQL is a 32-bit integer with a range from -2147483648 to +2147483647. On the other hand, NUMERIC (10) has a maximum of 10 digits, but the range is from -9999999999 to +9999999999, so it is wider than the INTEGER type. Since INTEGER can be calculated by native CPU operation, it is high speed, whereas NUMERIC is low speed because it performs decimal operation. Therefore, if the value range is always within the range of INTEGER, it is often preferable to set it to INTEGER type, but if it does not fit within the INTEGER type range, such as when it may be a very large integer, NUMERIC must be used.

REAL is a single precision floating point number, precision is about 6 digits, DOUBLE PRECISION is a double precision floating point number and precision is 15 digits, but internally it is expressed as a binary number. Therefore, it is different from the NUMERIC type which is a decimal number. In particular, it is necessary to be aware that accidental errors occur in REAL and DOUBLE PRECISION when decimal operation is performed. For example, since 0.1 of a decimal number can not be accurately represented by a binary number, they are not equal when 0.1 of REAL type is compared with 0.1 of NUMERIC type. When executing numerical calculation at high speed, it is better to use REAL / DOUBLE PRECISION, but it is often desirable to use NUMERIC when calculating the amount.

TIt is correct that A to D are all written in the former half, but the latter part is incorrect.

Therefore, the correct answer is E.