Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

COMMENT

COMMENT

Purpose

Use the COMMENT statement to add a comment about a table, view, materialized view, or column into the data dictionary.

You can view the comments on a particular table or column by querying the data dictionary views USER_TAB_COMMENTS, DBA_TAB_COMMENTS, or ALL_TAB_ COMMENTS or USER_COL_COMMENTS, DBA_COL_COMMENTS, or ALL_COL_ COMMENTS.

To drop a comment from the database, set it to the empty string ’ ’.

See Also:

"Comments" on page 2-90 for more information on associating comments with SQL statements and schema objects

Oracle9i Database Reference for information on the data dictionary views

Prerequisites

The object about which you are adding a comment must be in your own schema or:

You must have COMMENT ANY TABLE system privilege to add a comment to a table, view, or materialized view.

You must have the COMMENT ANY INDEXTYPE system privilege to add a comment to an indextype.

You must have the COMMENT ANY OPERATOR system privilege to add a comment to an operator.

12-72 Oracle9i SQL Reference

COMMENT

Syntax comment::=

schema

table

.

TABLE

view

materialized_view

 

schema

table

 

 

 

 

 

 

 

.

 

 

 

 

 

 

 

COLUMN

view

.

column

 

 

 

 

C0MMENT

ON

materialized_view

 

IS

text

;

 

 

 

 

 

 

 

 

 

schema

.

 

 

 

 

 

 

 

OPERATOR

operator

 

 

 

 

 

 

 

schema

.

 

 

 

 

 

 

 

INDEXTYPE

indextype

 

 

 

 

 

 

Semantics

TABLE Clause

Specify the schema and name of the table, view, or materialized view to be commented. If you omit schema, then Oracle assumes the table, view, or materialized view is in your own schema.

COLUMN Clause

Specify the name of the column of a table, view, or materialized view to be commented. If you omit schema, then Oracle assumes the table, view, or materialized view is in your own schema.

IS ’text

Specify the text of the comment.

See Also: "Text Literals" on page 2-54 for a syntax description of ’text’

OPERATOR Clause

Specify the name of the operator to be commented. If you omit schema, then Oracle assumes the operator is in your own schema.

SQL Statements: ALTER TRIGGER to COMMIT 12-73

COMMENT

INDEXTYPE Clause

Specify the name of the indextype to be commented. If you omit schema, then Oracle assumes the indextype is in your own schema.

Example

Creating Comments: Example To insert an explanatory remark on the job_id column of the employees table, you might issue the following statement:

COMMENT ON COLUMN employees.job_id

IS ’abbreviated job title’;

To drop this comment from the database, issue the following statement:

COMMENT ON COLUMN employees.job_id IS ’ ’;

12-74 Oracle9i SQL Reference

COMMIT

COMMIT

Purpose

Use the COMMIT statement to end your current transaction and make permanent all changes performed in the transaction. A transaction is a sequence of SQL statements that Oracle treats as a single unit. This statement also erases all savepoints in the transaction and releases the transaction’s locks.

Note: Oracle issues an implicit COMMIT before and after any data definition language (DDL) statement.

You can also use this statement to

Commit an in-doubt distributed transaction manually

Terminate a read-only transaction begun by a SET TRANSACTION statement.

Oracle Corporation recommends that you explicitly end every transaction in your application programs with a COMMIT or ROLLBACK statement, including the last transaction, before disconnecting from Oracle. If you do not explicitly commit the transaction and the program terminates abnormally, then the last uncommitted transaction is automatically rolled back.

A normal exit from most Oracle utilities and tools causes the current transaction to be committed. A normal exit from an Oracle precompiler program does not commit the transaction and relies on Oracle to roll back the current transaction.

See Also:

Oracle9i Database Concepts for more information on transactions

SET TRANSACTION on page 18-50 for more information on specifying characteristics of a transaction

Prerequisites

You need no privileges to commit your current transaction.

To manually commit a distributed in-doubt transaction that you originally committed, you must have FORCE TRANSACTION system privilege. To manually commit a distributed in-doubt transaction that was originally committed by another user, you must have FORCE ANY TRANSACTION system privilege.

SQL Statements: ALTER TRIGGER to COMMIT 12-75

COMMIT

Syntax commit::=

 

COMMENT

 

text

 

 

 

 

 

 

,

integer

WORK

FORCE

 

text

 

COMMIT

 

 

 

 

 

;

Semantics

WORK

The WORK keyword is supported for compliance with standard SQL. The statements COMMIT and COMMIT WORK are equivalent.

COMMENT Clause

Specify a comment to be associated with the current transaction. The ’text’ is a quoted literal of up to 255 bytes that Oracle stores in the data dictionary view DBA_ 2PC_PENDING along with the transaction ID if the transaction becomes in doubt.

See Also: COMMENT on page 12-72 for more information on adding comments to SQL statements

FORCE Clause

In a distributed database system, the FORCE clause lets you manually commit an in-doubt distributed transaction. The transaction is identified by the ’text’ containing its local or global transaction ID. To find the IDs of such transactions, query the data dictionary view DBA_2PC_PENDING. You can use integer to specifically assign the transaction a system change number (SCN). If you omit integer, then the transaction is committed using the current SCN.

Note: A COMMIT statement with a FORCE clause commits only the specified transaction. Such a statement does not affect your current transaction.

Restriction on FORCE COMMIT statements using the FORCE clause are not supported in PL/SQL.

12-76 Oracle9i SQL Reference

COMMIT

See Also: Oracle9i Heterogeneous Connectivity Administrator’s Guide for more information on these topics

Examples

Committing an Insert: Example This statement inserts a row into the hr.regions table and commits this change:

INSERT INTO regions VALUES (5, ’Antarctica’);

COMMIT WORK;

Commenting on COMMIT: Example The following statement commits the current transaction and associates a comment with it:

COMMIT

COMMENT ’In-doubt transaction Code 36, Call (415) 555-2637’;

If a network or machine failure prevents this distributed transaction from committing properly, then Oracle stores the comment in the data dictionary along with the transaction ID. The comment indicates the part of the application in which the failure occurred and provides information for contacting the administrator of the database where the transaction was committed.

Forcing an In-Doubt Transaction: Example The following statement manually commits an in-doubt distributed transaction:

COMMIT FORCE ’22.57.53’;

SQL Statements: ALTER TRIGGER to COMMIT 12-77

COMMIT

12-78 Oracle9i SQL Reference

Соседние файлы в папке Oracle selected docs