Sample Exam Questions
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/02
Many of the operators used in various computations are common across many programming languages, including SQL. However, it is important to note that some operators may not be available or may serve different purposes depending on the language. This is also true in SQL, where the availability and purpose of certain operators can vary depending on the type of RDBMS.
Most languages use the / operator for division. In many languages, including SQL, if both the dividend and divisor are integers, the quotient is also an integer. If at least one of them is a real number, the quotient is a real number. The // operator, which calculates the integer quotient by discarding the remainder, was introduced in Python 3.x. However, it is not available in PostgreSQL. In Python 3, the quotient is a real number even when dividing integers.
Many languages use the % operator to calculate the remainder of a division. The SQL standard does not define the % operator, and instead uses the MOD function. However, some databases, including PostgreSQL, allow the use of the % operator to calculate the remainder.
For exponentiation, many languages use the ** or ^ operator. In SQL, it is common to use the POW or POWER functions. However, in addition to POW and POWER, PostgreSQL also supports the ^ operator for exponentiation. The ** operator is not available.
Many languages use || for logical OR, but in SQL, the keyword OR is used as the logical OR operator. || is used for string concatenation.
Many languages use + for string concatenation, but SQL uses ||. + is strictly an operator for addition, so expressions like 'abc' + 'def' will result in an error. Incidentally, '1' + '2' will also result in an error, but '1' + 2 or 1 + '2' will result in 3.
Therefore, the correct answer is B.
Even if you are a database engineer, it's not enough to just know SQL. For example, in web-based systems, you often use it in combination with languages like PHP, Python, and JavaScript. There are several examples where the same operation uses different operators or functions, or the same operator is used for different purposes, so be careful not to get confused.
© EDUCO All Rights Reserved.