Movatterモバイル変換


[0]ホーム

URL:


Skip Headers

Go to Documentation Home
Go to Book List
Go to Table of Contents
Go to Index
Go to Master Index
Go to Feedback page

Go to previous page
Go to next page

You can associate comments with SQL statements and schema objects.

Comments can make your application easier for you to read and maintain. For example, you can include a comment in a statement that describes the purpose of the statement within your application. With the exception of hints, comments within SQL statements do not affect the statement execution. Please refer to"Hints " on using this particular form of comment.

A comment can appear between any keywords, parameters, or punctuation marks in a statement. You can include a comment in a statement in two ways:

  • Begin the comment with a slash and an asterisk (/*). Proceed with the text of the comment. This text can span multiple lines. End the comment with an asterisk and a slash (*/). The opening and terminating characters need not be separated from the text by a space or a line break.

  • Begin the comment with -- (two hyphens). Proceed with the text of the comment. This text cannot extend to a new line. End the comment with a line break.

Some of the tools used to enter SQL have additional restrictions. For example, if you are using SQL*Plus, by default you cannot have a blank line inside a multiline comment. For more information, please refer to the documentation for the tool you use as an interface to the database.

A SQL statement can contain multiple comments of both styles. The text of a comment can contain any printable characters in your database character set.



These statements contain many comments:

SELECT last_name, salary + NVL(commission_pct, 0),    job_id, e.department_id/* Select all employees whose compensation isgreater than that of Pataballa.*/  FROM employees e, departments d       /*The DEPARTMENTS table is used to get the department name.*/  WHERE e.department_id = d.department_id    AND salary + NVL(commission_pct,0) >   /* Subquery:       */   (SELECT salary + NVL(commission_pct,0)                 /* total compensation is salar + commission_pct */      FROM employees       WHERE last_name = 'Pataballa');SELECT last_name,                    -- select the name    salary + NVL(commission_pct, 0),-- total compensation    job_id,                         -- job    e.department_id                 -- and department  FROM employees e,                 -- of all employees       departments d  WHERE e.department_id = d.department_id    AND salary + NVL(commission_pct, 0) >  -- whose compensation                                            -- is greater than      (SELECT salary + NVL(commission_pct,0)  -- the compensation    FROM employees     WHERE last_name = 'Pataballa')        -- of Pataballa.;

You can associate a comment with a table, view, materialized view, or column using theCOMMENT command. Comments associated with schema objects are stored in the data dictionary. Please refer toCOMMENT for a description of comments.

You can use comments in a SQL statement to pass instructions, orhints, to the Oracle Database optimizer. The optimizer uses these hints as suggestions for choosing an execution plan for the statement.

A statement block can have only one comment containing hints, and that comment must follow theSELECT,UPDATE,INSERT, orDELETE keyword. The following syntax shows hints contained in both styles of comments that Oracle supports within a statement block.

{DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */

or

{DELETE|INSERT|SELECT|UPDATE} --+ hint [text] [hint[text]]...

where:

  • DELETE,INSERT,SELECT, orUPDATE is aDELETE,INSERT,SELECT, orUPDATE keyword that begins a statement block. Comments containing hints can appear only after these keywords.

  • + is a plus sign that causes Oracle to interpret the comment as a list of hints. The plus sign must follow immediately after the comment delimiter (no space is permitted).

  • hint is one of the hints discussed in this section. The space between the plus sign and the hint is optional. If the comment contains multiple hints, then separate the hints by at least one space.

  • text is other commenting text that can be interspersed with the hints.

Oracle Database treats misspelled hints as regular comments and does not return an error.

Many hints can apply both to specific tables or indexes and more globally to tables within a view or to columns that are part of indexes. The syntactic elementstablespec andindexspec define theseglobal hints. For information on when to use global hints and how Oracle interprets them, please refer toOracle Database Performance Tuning Guide.



Description of tablespec.gif follows
Description of the illustration tablespec.gif



Description of indexspec.gif follows
Description of the illustration indexspec.gif

Table 2-22 lists the hints by functional category and contains cross-references to its syntax. (In HTML and PDF, the cross-references are hyperlinks.) An alphabetical listing of the hints, including syntax, follows the table.


Oracle Database Performance Tuning Guide for more information on using hints to optimize SQL statements and on detailed information about using thetablespec andindexspec syntax

Optimization Goals and ApproachesALL_ROWS

FIRST_ROWS

all_rows_hint::=

first_rows_hint::=


RULErule_hint::=
Access Path HintsCLUSTERcluster_hint::=
FULLfull_hint::=
HASHhash_hint::=
INDEX

NO_INDEX

index_hint::=

no_index_hint::=


INDEX_ASC

INDEX_DESC

index_asc_hint::=

index_desc_hint::=


INDEX_COMBINEindex_combine_hint::=
INDEX_JOINindex_join_hint::=
INDEX_FFSindex_ffs_hint::=
INDEX_SSindex_ss_hint::=
INDEX_SS_ASCindex_ss_asc_hint::=
INDEX_SS_DESCindex_ss_desc_hint::=
NO_INDEX_FSSno_index_ffs_hint::=
NO_INDEX_SSno_index_ss_hint::=
Join Order HintsORDEREDordered_hint::=
LEADINGleading_hint::=
Join Operation HintsUSE_HASH

NO_USE_HASH

use_hash_hint::=

no_use_hash_hint::=


USE_MERGE

NO_USE_MERGE

use_merge_hint::=

no_use_merge_hint::=


USE_NL

USE_NL_WITH_INDEX

NO_USE_NL

use_nl_hint::=

use_nl_with_index_hint::=

no_use_nl_hint::=


Parallel Execution HintsPARALLEL

NO_PARALLEL

parallel_hint::=

no_parallel_hint::=


PARALLEL_INDEX

NO_PARALLEL_INDEX

parallel_index_hint::=

no_parallel_index_hint::=


PQ_DISTRIBUTEpq_distribute_hint::=
Query Transformation HintsFACT

NOFACT

fact_hint::=

no_fact_hint::=


MERGE

NO_MERGE

merge_hint::=

no_merge_hint::=


NO_EXPANDno_expand_hint::=
REWRITE

NO_REWRITE

rewrite_hint::=

no_rewrite_hint::=


UNNEST

NO_UNNEST

unnest_hint::=

no_unnest_hint::=


STAR_TRANSFORMATION

NO_STAR_TRANSFORMATION

star_transformation_hint::=

no_star_transformation_hint::=


NO_QUERY_TRANSFORAMTIONno_query_transformation_hint::=
USE_CONCATuse_concat_hint::=
Other HintsAPPEND

NOAPPEND

append_hint::=

noappend_hint::=


CACHE

NOCACHE

cache_hint::=

nocache_hint::=


CURSOR_SHARING_EXACTcursor_sharing_exact_hint::=
DRIVING_SITEdriving_site_hint::=
DYNAMIC_SAMPLINGdynamic_sampling_hint::=
PUSH_PRED

NO_PUSH_PRED

push_pred_hint::=

no_push_pred_hint::=


PUSH_SUBQ

NO_PUSH_SUBQ

push_subq_hint::=

no_push_subq_hint::=


QB_NAMEqb_name::=
SPREAD_MIN_ANALYSISspread_min_analysis_hint::=



Description of all_rows_hint.gif follows
Description of the illustration all_rows_hint.gif



Description of append_hint.gif follows
Description of the illustration append_hint.gif



Description of cache_hint.gif follows
Description of the illustration cache_hint.gif



Description of cluster_hint.gif follows
Description of the illustration cluster_hint.gif



Description of cursor_sharing_exact_hint.gif follows
Description of the illustration cursor_sharing_exact_hint.gif



Description of driving_site_hint.gif follows
Description of the illustration driving_site_hint.gif



Description of dynamic_sampling_hint.gif follows
Description of the illustration dynamic_sampling_hint.gif



Description of fact_hint.gif follows
Description of the illustration fact_hint.gif



Description of first_rows_hint.gif follows
Description of the illustration first_rows_hint.gif



Description of full_hint.gif follows
Description of the illustration full_hint.gif



Description of hash_hint.gif follows
Description of the illustration hash_hint.gif



Description of index_hint.gif follows
Description of the illustration index_hint.gif



Description of index_asc_hint.gif follows
Description of the illustration index_asc_hint.gif



Description of index_combine_hint.gif follows
Description of the illustration index_combine_hint.gif



Description of index_desc_hint.gif follows
Description of the illustration index_desc_hint.gif



Description of index_ffs_hint.gif follows
Description of the illustration index_ffs_hint.gif



Description of index_join_hint.gif follows
Description of the illustration index_join_hint.gif



Description of index_ss_hint.gif follows
Description of the illustration index_ss_hint.gif



Description of index_ss_asc_hint.gif follows
Description of the illustration index_ss_asc_hint.gif



Description of index_ss_desc_hint.gif follows
Description of the illustration index_ss_desc_hint.gif



Description of leading_hint.gif follows
Description of the illustration leading_hint.gif



Description of merge_hint.gif follows
Description of the illustration merge_hint.gif



Description of noappend_hint.gif follows
Description of the illustration noappend_hint.gif



Description of nocache_hint.gif follows
Description of the illustration nocache_hint.gif



Description of no_expand_hint.gif follows
Description of the illustration no_expand_hint.gif



Description of no_fact_hint.gif follows
Description of the illustration no_fact_hint.gif



Description of no_index_hint.gif follows
Description of the illustration no_index_hint.gif



Description of no_index_ffs_hint.gif follows
Description of the illustration no_index_ffs_hint.gif



Description of no_index_ss_hint.gif follows
Description of the illustration no_index_ss_hint.gif



Description of no_merge_hint.gif follows
Description of the illustration no_merge_hint.gif



Description of no_parallel_hint.gif follows
Description of the illustration no_parallel_hint.gif



You cannot parallelize a query involving a nested table.



Description of no_parallel_index_hint.gif follows
Description of the illustration no_parallel_index_hint.gif



Description of no_push_pred_hint.gif follows
Description of the illustration no_push_pred_hint.gif



Description of no_push_subq_hint.gif follows
Description of the illustration no_push_subq_hint.gif



Description of no_rewrite_hint.gif follows
Description of the illustration no_rewrite_hint.gif



Description of no_query_transformatn_hint.gif follows
Description of the illustration no_query_transformatn_hint.gif



Description of no_star_transformation_hint.gif follows
Description of the illustration no_star_transformation_hint.gif



Description of no_unnest_hint.gif follows
Description of the illustration no_unnest_hint.gif



Description of no_use_hash_hint.gif follows
Description of the illustration no_use_hash_hint.gif



Description of no_use_merge_hint.gif follows
Description of the illustration no_use_merge_hint.gif



Description of no_use_nl_hint.gif follows
Description of the illustration no_use_nl_hint.gif



Description of ordered_hint.gif follows
Description of the illustration ordered_hint.gif



Description of parallel_hint.gif follows
Description of the illustration parallel_hint.gif

Oracle ignores parallel hints on a temporary table. Please refer toCREATE TABLE andOracle Database Concepts for more information on parallel execution.



Description of parallel_index_hint.gif follows
Description of the illustration parallel_index_hint.gif



Description of pq_distribute_hint.gif follows
Description of the illustration pq_distribute_hint.gif


Oracle Database Performance Tuning Guide for the permitted combinations of distributions for the outer and inner join tables



Description of push_pred_hint.gif follows
Description of the illustration push_pred_hint.gif



Description of push_subq_hint.gif follows
Description of the illustration push_subq_hint.gif



Description of qb_name_hint.gif follows
Description of the illustration qb_name_hint.gif



Description of rewrite_hint.gif follows
Description of the illustration rewrite_hint.gif



Description of rule_hint.gif follows
Description of the illustration rule_hint.gif



Description of spread_min_analysis_hint.gif follows
Description of the illustration spread_min_analysis_hint.gif



Description of star_transformation_hint.gif follows
Description of the illustration star_transformation_hint.gif



Description of unnest_hint.gif follows
Description of the illustration unnest_hint.gif



Description of use_concat_hint.gif follows
Description of the illustration use_concat_hint.gif



Description of use_hash_hint.gif follows
Description of the illustration use_hash_hint.gif



Description of use_merge_hint.gif follows
Description of the illustration use_merge_hint.gif



Description of use_nl_hint.gif follows
Description of the illustration use_nl_hint.gif



Description of use_nl_with_index_hint.gif follows
Description of the illustration use_nl_with_index_hint.gif


Go to previous page
Go to next page
Oracle

Go to Documentation Home
Go to Book List
Go to Table of Contents
Go to Index
Go to Master Index
Go to Feedback page

[8]ページ先頭

©2009-2025 Movatter.jp