Add or remove quotes for identifiers

The Add or remove quotes for identifiers feature enables you to add or remove quotes for identifiers within the current SQL document or a selected code block, without changing their case. This feature doesn’t affect text in strings (' '), quotes (" "), or comments (--, /* */). It also doesn’t change the original identifier case.

Add quotes to identifiers

You can add quotes to all identifiers in one of these ways:

  • In the top menu, select Edit > Advanced > Add Quotes to All Identifiers.
  • Right-click anywhere in a SQL document and select Refactoring > Add Quotes to All Identifiers.
  • Press Ctrl+K, Ctrl+[.

Tip

To undo the change, press Ctrl+Z. The script returns to its previous state, and the cursor position remains unchanged.

Remove quotes from identifiers

You can remove unnecessary quotes from all identifiers in one of these ways:

  • In the top menu, select Edit > Advanced > Remove Unnecessary Quotes.
  • Right-click anywhere in a SQL document and select Refactoring > Remove Unnecessary Quotes.
  • Press Ctrl+K, Ctrl+].

Note

Remove Unnecessary Quotes doesn’t affect identifiers that:

  • Contain spaces.
  • Contain special symbols, for example, @, $, or %.
  • Match the keywords, for example, SELECT or FROM.
  • Contain lowercase characters.

Example

The following script shows identifiers before quotes are added:

CREATE OR REPLACE PROCEDURE GET_CUSTOMER_DETAILS(P_CUSTOMER_ID IN NUMBER) IS
"V_NAME" VARCHAR2(255);
V_CREDIT_LIMIT NUMBER(8, 2);
BEGIN
EXECUTE IMMEDIATE 'SELECT "NAME", CREDIT_LIMIT FROM CUSTOMERS WHERE CUSTOMER_ID = ' || P_CUSTOMER_ID
INTO V_NAME, V_CREDIT_LIMIT;
 
DBMS_OUTPUT.PUT_LINE('Customer Name: ' || V_NAME);
DBMS_OUTPUT.PUT_LINE('Credit Limit: ' || V_CREDIT_LIMIT);
 
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No customer found with ID ' || P_CUSTOMER_ID);
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);
END GET_CUSTOMER_DETAILS;
 
SELECT s."ORDER", s."TEST" FROM "SELECT" s

Before: Add quotes to all identifiers in the query

After you use Add Quotes to All Identifiers, all applicable identifiers are enclosed in quotes automatically.

CREATE OR REPLACE PROCEDURE "GET_CUSTOMER_DETAILS"("P_CUSTOMER_ID" IN NUMBER) IS
"V_NAME" VARCHAR2(255);
"V_CREDIT_LIMIT" NUMBER(8, 2);
BEGIN
EXECUTE IMMEDIATE 'SELECT "NAME", CREDIT_LIMIT FROM CUSTOMERS WHERE CUSTOMER_ID = ' || "P_CUSTOMER_ID"
INTO "V_NAME", "V_CREDIT_LIMIT";
 
DBMS_OUTPUT.PUT_LINE('Customer Name: ' || "V_NAME");
DBMS_OUTPUT.PUT_LINE('Credit Limit: ' || "V_CREDIT_LIMIT");
 
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No customer found with ID ' || "P_CUSTOMER_ID");
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);
END "GET_CUSTOMER_DETAILS";
 
SELECT "s"."ORDER", "s"."TEST" FROM "SELECT" "s"

After: Add quotes to all identifiers in the query