O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Operators

An operator is a symbol specifying an action that is performed on one or more expressions. Operators are used most often in DELETE , INSERT, SELECT, or UPDATE statements, but also are used frequently in the creation of database objects, such as stored procedures, functions, triggers, and views.

Operators typically fall into these categories:

Arithmetic operators

Supported by all databases

Assignment operators

Supported by all databases

Bitwise operators

Supported by Microsoft SQL Server

Comparison operators

Supported by all databases

Logical operators

Supported by DB2, Oracle, SQL Server, and PostgreSQL

Unary operators

Supported by DB2, Oracle, and SQL Server

Arithmetic operators

Arithmetic operators perform mathematical operations on two expressions of any datatypes in the numeric datatype category. See Table 2-2 for a listing of the arithmetic operators.

Table 2-2. Arithmetic operators

Arithmetic operator

Meaning

+

Addition

-

Subtraction

*

Multiplication

/

Division

%

Modula (SQL Server only); returns the remainder of a division operation as an integer value

Tip

In DB2, Oracle, and SQL Server, the + and - operators also can be used to perform arithmetic operations on date values.

Assignment operators

Except in Oracle, which uses :=, the assignment operator (=) assigns a value to a variable or the alias of a column heading. In SQL Server, the keyword AS may serve as an operator for assigning table- or column-heading aliases.

Bitwise operators ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required