Home > Database > Oracle > Usage of (+ in oracle

Usage of (+ in oracle

下次还敢
Release: 2024-05-08 20:12:16
Original
791 people have browsed it

The plus sign ( ) operator in Oracle can be used to: connect strings, numbers, dates and time intervals; handle NULL values ​​and convert NULL to non-NULL values; convert data types to string types.

Usage of (+ in oracle

Usage of plus sign ( ) operator in Oracle

The plus sign ( ) operator in Oracle has many Uses include:

1. Connecting strings

SELECT 'Hello' || ' World';
-- 输出:HelloWorld
Copy after login

2. Connecting numbers

SELECT 12 + 34;
-- 输出:46
Copy after login

3 . Connection date

SELECT DATE '2023-01-01' + INTERVAL '1' DAY;
-- 输出:2023-01-02
Copy after login

4. Connection time interval

SELECT INTERVAL '1' HOUR + INTERVAL '30' MINUTE;
-- 输出:INTERVAL '1:30' HOUR TO MINUTE
Copy after login

5. NULL processing

plus sign( ) operator can convert NULL values ​​to non-NULL values, as follows:

  • String: NULL string = string
  • Number : NULL number = number
  • Date: NULL date = date
  • Time interval: NULL time interval = Time interval
SELECT NULL + 'Hello';
-- 输出:Hello

SELECT NULL + 12;
-- 输出:12
Copy after login

6. Convert data type

The plus sign ( ) operator can implicitly convert the data type to a string type.

SELECT '12' + 34;
-- 输出:'1234'
Copy after login

Note:

  • The plus sign () operator has higher priority than the multiplication sign (*) and division sign (/).
  • For null or NULL values, the behavior of the plus () operator follows Oracle's null value handling rules.

The above is the detailed content of Usage of (+ in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template