Share this page:

oracle tutorial

Oracle/PLSQL: CONCAT Function

This Oracle tutorial explains how to use the Oracle/PLSQL CONCAT function with syntax and examples.

Description

The Oracle/PLSQL CONCAT function allows you to concatenate two strings together.

Syntax

The syntax for the Oracle/PLSQL CONCAT function is:

CONCAT( string1, string2 )

Parameters or Arguments

string1 is the first string to concatenate.

string2 is the second string to concatenate.

Note

Applies To

The CONCAT function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle CONCAT function examples and explore how to use the CONCAT function in Oracle/PLSQL.

For example:

CONCAT('Tech on', ' the Net')
Result: 'Tech on the Net'

CONCAT('a', 'b')
Result: 'ab'

Frequently Asked Questions

Question: How can you use the CONCAT function to concatenate more than 2 strings together?

Answer: Since the CONCAT function will only let you concatenate 2 strings, you will need to nest multiple CONCAT functions to concatenate more than 2 strings together.

For example, to concatenate 3 strings, you could nest the CONCAT function as follows:

CONCAT( CONCAT( string1, string2 ), string3 )

Or you could nest the CONCAT function as follows, if you wanted to concatenate 4 strings:

CONCAT( CONCAT( CONCAT( string1, string2 ), string3 ), string4 )

Here is an example provided by Ruth that demonstrates how to nest multiple CONCAT functions to concatenate 6 strings:

CONCAT( CONCAT( CONCAT( CONCAT( CONCAT(
 'I like ', t.type_desc_column), ' cake with '), t.icing_desc_column),' and a '),
   t.fruit_desc_column)

The CONCAT function is one method to concatenate strings in Oracle. An alternative to using the CONCAT function would be to use the || operator to catenatenate multiple strings, as follows:

'I like ' || t.type_desc_column || ' cake with ' || t.icing_desc_column || ' and a '
  || t.fruit_desc_column