<<<<<<< HEAD quote_ident | H2 | SQLDoc
Skip to main content

quote_ident

1. QUOTE_IDENT Function

======= quote_ident | H2 Function | SQLDoc

quote_ident

1. QUOTE_IDENT Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The QUOTE_IDENT function in H2 database is used to quote an identifier, such as a table name or column name, to ensure correct handling of special characters or reserved keywords.

2. Syntax

The syntax for the QUOTE_IDENT function in H2 database is as follows:

QUOTE_IDENT(identifier)

Arguments

  • identifier: The identifier to be quoted. It should be a string value representing the identifier.

Return

  • The QUOTE_IDENT function returns the quoted version of the identifier.

3. Notes

  • The QUOTE_IDENT function in H2 database is useful when dealing with identifiers that contain special characters or reserved keywords. Quoting the identifier ensures that it is correctly interpreted by the database engine.
  • The QUOTE_IDENT function adds double quotes around the identifier.
  • If the input identifier is already quoted, the QUOTE_IDENT function will add an additional set of double quotes. To avoid this, you can use the IS_QUOTED_IDENT function to check if the identifier is already quoted before applying the QUOTE_IDENT function.

4. Examples

Here are a few examples demonstrating the usage of the QUOTE_IDENT function in H2 database:

Example 1 - Quoting a table name:

SELECT QUOTE_IDENT('users') AS quoted_table_name;

Output:

quoted_table_name
-----------------
"users"

Example 2 - Quoting a column name:

SELECT QUOTE_IDENT('first name') AS quoted_column_name;

Output:

quoted_column_name
------------------
"first name"

Example 3 - Quoting an already quoted identifier:

SELECT QUOTE_IDENT('"users"') AS quoted_identifier;

Output:

quoted_identifier
-----------------
"""users"""
  • IS_QUOTED_IDENT - Check if an identifier is already quoted