- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the arithmetic and character operators in DBMS?
SQL operators manipulate individual data items and return a result. The data items are called operands. SQL supports unary, binary and set operators.
Let’s see the levels of SQL operator precedence from higher to lower.
- Unary+ - arithmetic operators {PRIOR operator}
- / arithmetic operators
- Binary + - arithmetic operator, || character operators
- All comparison operators
- NOT logical operator
- AND logical operator
- OR logical operator
Arithmetic operators
These operators are used to manipulate the numeric operands. The – operator is also used in data arithmetic.
+(unary) − Makes operant positive.
For example,
select +3 from dual;
-(unary) − Negates operand.
For example,
select * from items where itemsold=-1; Select * from emp where -sal<0;
/ (Division) − It is a binary operator which is used to divide numbers and dates.
For example,
select sal/10 from emp;
*(Multiplication) − It is a binary operator used to multiply two operands.
For example,
select sal*10 from emp; Update emp SET sal=sal*2.5;
+ (addition) − Add two operands using the binary operator.
For example,
select 30+20;
The output will be 50.
-(subtraction) − Subtracts two operands, it is a binary operator.
For example,
select sal-200 from emp;
Character operators
They are used in expression to manipulate character strings. It is denoted as ||. It is used to concatenate character strings.
For example,
select the name of the employee is:’ || ename from emp;
Concatenating character strings
We can concatenate character string with the following result −
Concatenating two-character strings result in another character string. SQL preserves trailing blanks in character strings by concatenation, regardless of the strings datatype. SQL provides the CONCAT character function as an alternative to the vertical bar operator.
SQL treats zero-length character strings as nulls. When you concatenate a zero-length character string with another operand the result is always the other operand. A null value can only result from the concatenation of two null strings.
- Related Articles
- What are the arithmetic operators in Java?
- What are arithmetic operators in C#?
- What are Arithmetic Operators in JavaScript?
- What are different arithmetic operators in Python?
- Arithmetic Operators in C++
- Perl Arithmetic Operators
- Java arithmetic operators
- Python Arithmetic Operators
- What is operand of arithmetic operators in Java
- Explain the logical operators in DBMS
- Arithmetic operators in Dart Programming
- Character arithmetic in C
- Relational Set Operators in DBMS
- Explain set operators in DBMS
- Simple Arithmetic Operators Example Program In C++
