Skip Headers
Oracle® Database SQL Reference
10g Release 2 (10.2)

Part Number B14200-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

Arithmetic Operators

You can use an arithmetic operator with one or two arguments to negate, add, subtract, multiply, and divide numeric values. Some of these operators are also used in datetime and interval arithmetic. The arguments to the operator must resolve to numeric datatypes or to any datatype that can be implicitly converted to a numeric datatype.

Unary arithmetic operators return the same datatype as the numeric datatype of the argument. For binary arithmetic operators, Oracle determines the argument with the highest numeric precedence, implicitly converts the remaining arguments to that datatype, and returns that datatype. Table 4-2 lists arithmetic operators.

See Also:

Table 2-10, "Implicit Type Conversion Matrix" for more information on implicit conversion, "Numeric Precedence" for information on numeric precedence, and "Datetime/Interval Arithmetic"

Table 4-2 Arithmetic Operators

Operator Purpose Example

+ -

When these denote a positive or negative expression, they are unary operators.

SELECT * FROM order_items
 WHERE quantity = -1;
SELECT * FROM employees
  WHERE -salary < 0;

+ -

When they add or subtract, they are binary operators.

SELECT hire_date 
  FROM employees
  WHERE SYSDATE - hire_date
  > 365;

* /

Multiply, divide. These are binary operators.

UPDATE employees
  SET salary = salary * 1.1;

Do not use two consecutive minus signs (--) in arithmetic expressions to indicate double negation or the subtraction of a negative value. The characters -- are used to begin comments within SQL statements. You should separate consecutive minus signs with a space or parentheses. Please refer to "Comments" for more information on comments within SQL statements.