Updated on 2025-10-10 GMT+08:00

CREATE OUTLINE

Function

Creates an outline for a specified sql_hash.

Precautions

  • If there are syntax errors in the outline of outline_text, error message "syntax error" will be displayed.
  • After the syntax execution is successful, a row will be inserted into the SQL_OUTLINE system catalog.
  • Only the database administrator or users with the gs_role_sql_management role can execute this syntax.

Syntax

1
CREATE OUTLINE outline_name FOR sql_hash USING outline_text;

Parameter Description

  • outline_name

    Specifies the name of the new outline.

  • sql_hash

    Create a sql_hash of the SQL statement corresponding to the outline.

  • outline_text

    Specifies the content of the outline you want to create. The value type is text and must be enclosed in single quotation marks ('').

    Only one hint block is allowed. If there are multiple hint blocks, combine them into one.

Examples

Create an outline as the database administrator.

1
2
3
4
5
6
7
CREATE OUTLINE outline_test1 FOR sql_be2995e824abb8b712b69fca4825b532 USING '/*+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) */';
CREATE OUTLINE outline_test2 FOR sql_be2995e824abb8b712b69fca4825b532 USING
'/*+
    begin_outline_data
     leading(@sel$1 public.t1@sel$1 s1.t2@sel$1)
    end_outline_data
 */';

When a database administrator creates an outline, if outline_text specifies multiple hint blocks, a syntax error is reported. Only after thees hint blocks specified by outline_text are combined into one, can the outline be created.

1
2
3
4
5
6
7
8
CREATE OUTLINE outline_test3 FOR sql_be2995e824abb8b712b69fca4825b532 USING '/*+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) */ /*+ mergejoin(@sel$1 t1@sel$1 t1@sel$2)*/';
ERROR:  LINE 1: syntax error at '*'

CREATE OUTLINE outline_test3 FOR sql_be2995e824abb8b712b69fca4825b532 USING '/*+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) */' '/*+ mergejoin(@sel$1 t1@sel$1 t1@sel$2)*/';
ERROR:  syntax error at or near "'/*+ mergejoin(@sel$1 t1@sel$1 t1@sel$2)*/'"
LINE 1: ...+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) */' '/*+ merge...
                                                             ^
CREATE OUTLINE outline_test3 FOR sql_be2995e824abb8b712b69fca4825b532 USING '/*+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) mergejoin(@sel$1 t1@sel$1 t1@sel$2)*/';

An error is reported when a common user creates an outline.

1
2
CREATE OUTLINE outline_test4 FOR sql_be2995e824abb8b712b69fca4825b532 USING '/*+ leading(@sel$1 public.t1@sel$1 s1.t2@sel$1) */';
ERROR:  Permission denied to create outline.