tags:

views:

2735

answers:

2

What is the string concatenation operator in Oracle SQL?

Are there any "interesting" features I should be careful of?

(This seems obvious, but I couldn't find a previous question asking it).

+7  A: 

It is ||, for example:

select 'Mr ' || ename from emp;

The only "interesting" feature I can think of is that 'x' || null returns 'x', not null as you might perhaps expect.

Tony Andrews
I'd expect null from a logical operation... not sure I'd ever thought about a string operation.
Well of course Oracle treats null and '' as the same, and 'x' || '' = 'x' makes sense. But if you think of null as "undefined" or "unknown" then 'x' || null could be any string beginning with 'x' and so is itself "unknown"!
Tony Andrews
A: 

There's also concat, but it doesn't get used much

select concat('a','b') from dual;
Gary