set_transaction.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 110 行

7
110
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "SET TRANSACTION" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMESET TRANSACTION \- set the characteristics of the current transaction.SH SYNOPSIS.sp.nfSET TRANSACTION \fItransaction_mode\fR [, ...]SET SESSION CHARACTERISTICS AS TRANSACTION \fItransaction_mode\fR [, ...]where \fItransaction_mode\fR is one of:    ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }    READ WRITE | READ ONLY.sp.fi.SH "DESCRIPTION".PPThe \fBSET TRANSACTION\fR command sets thecharacteristics of the current transaction. It has no effect on anysubsequent transactions. \fBSET SESSIONCHARACTERISTICS\fR sets the default transactioncharacteristics for subsequent transactions of a session. Thesedefaults can be overridden by \fBSET TRANSACTION\fRfor an individual transaction..PPThe available transaction characteristics are the transactionisolation level and the transaction access mode (read/write orread-only)..PPThe isolation level of a transaction determines what data thetransaction can see when other transactions are running concurrently:.TP\fBREAD COMMITTED\fRA statement can only see rows committed before it began. Thisis the default..TP\fBSERIALIZABLE\fRAll statements of the current transaction can only see rows committedbefore the first query or data-modification statement was executed inthis transaction..PPThe SQL standard defines two additional levels, READUNCOMMITTED and REPEATABLE READ.In PostgreSQL READUNCOMMITTED is treated asREAD COMMITTED, while REPEATABLEREAD is treated as SERIALIZABLE..PPThe transaction isolation level cannot be changed after the first query ordata-modification statement (\fBSELECT\fR,\fBINSERT\fR, \fBDELETE\fR,\fBUPDATE\fR, \fBFETCH\fR, or\fBCOPY\fR) of a transaction has been executed. Seein the documentation for more information about transactionisolation and concurrency control..PPThe transaction access mode determines whether the transaction isread/write or read-only. Read/write is the default. When atransaction is read-only, the following SQL commands aredisallowed: INSERT, UPDATE,DELETE, and COPY FROM if thetable they would write to is not a temporary table; allCREATE, ALTER, andDROP commands; COMMENT,GRANT, REVOKE,TRUNCATE; and EXPLAIN ANALYZEand EXECUTE if the command they would execute isamong those listed. This is a high-level notion of read-only thatdoes not prevent all writes to disk..SH "NOTES".PPIf \fBSET TRANSACTION\fR is executed without a prior\fBSTART TRANSACTION\fR or \fBBEGIN\fR,it will appear to have no effect, since the transaction will immediatelyend..PPIt is possible to dispense with \fBSET TRANSACTION\fRby instead specifying the desired \fItransaction_modes\fR in\fBBEGIN\fR or \fBSTART TRANSACTION\fR..PPThe session default transaction modes can also be set by setting theconfiguration parameters default_transaction_isolationand default_transaction_read_only.(In fact \fBSET SESSION CHARACTERISTICS\fR is just averbose equivalent for setting these variables with \fBSET\fR.)This means the defaults can be set in the configuration file, via\fBALTER DATABASE\fR, etc. Consult in the documentationfor more information..SH "COMPATIBILITY".PPBoth commands are defined in the SQL standard.SERIALIZABLE is the default transactionisolation level in the standard. InPostgreSQL the default is ordinarilyREAD COMMITTED, but you can change it asmentioned above. Because of lack of predicate locking, theSERIALIZABLE level is not trulyserializable. See in the documentation for details..PPIn the SQL standard, there is one other transaction characteristicthat can be set with these commands: the size of the diagnosticsarea. This concept is specific to embedded SQL, and therefore isnot implemented in the PostgreSQL server..PPThe SQL standard requires commas between successive \fItransaction_modes\fR, but for historicalreasons PostgreSQL allows the commas to beomitted.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?