Reference Web page: http://www.php100.com/manual/PostgreSQL8/sql-set-transaction.html
Show transaction isolation level; View Transaction Isolation Levels
testdb=# show transaction isolation level;
Transaction_isolation
-----------------------
Read Committed
(1 Line Records)
Testdb=> SET TRANSACTION ISOLATION level READ UNCOMMITTED;
SET
-----
Set the time required to have the current transaction, if no transaction is going to end immediately, without any effect;
----
The Set TRANSACTION command sets the attributes for the current transaction. It has no effect on subsequent transactions.
Set session characteristics sets the default isolation level for each subsequent transaction in a session.
These defaults can be overridden by the SET TRANSACTION for a separate transaction.
The available transaction attributes are the transaction isolation level and the transaction access mode (read/write or read-only).
The isolation level of a transaction determines what data it can see when a transaction exists concurrently with other concurrently running transactions.
READ COMMITTED
A statement can only see the data before it starts. This is the default.
SERIALIZABLE
All statements in the current transaction can only see data that precedes the execution of the first query or the statement that modifies the data.
The SQL standard also defines two additional levels, read UNCOMMITTED and repeatable read.
In PostgreSQL, read UNCOMMITTED is treated as read COMMITTED, while Repeatable read is regarded as SERIALIZABLE.
The transaction access mode determines whether the transaction is read/write or read-only. Read/write is the default. If a transaction is read-only and the table being written is not a temporary table, then the following SQL command is not allowed: INSERT, Update,delete, and COPY to; all Create,alter, and DROP commands; Comment,grant,revo KE, TRUNCATE, and EXPLAIN ANALYZE and execute are not allowed. This is a high-level read-only concept that does not prevent all writes to disk
SET TRANSACTION Transaction_mode [, ...]
SET SESSION characteristics as TRANSACTION transaction_mode [, ...]
Here Transaction_mode is one of the following:
Isolation Level {SERIALIZABLE | Repeatable READ | READ COMMITTED | READ UNCOMMITTED} TRANSACTION ISOLATION LEVEL
READ WRITE | READ only Transactional access mode
Attention:
1, if START TRANSACTION or BEGIN is not executed before the SET TRANSACTION is executed, it will appear to be ineffective because the transaction will end immediately.
2, we can declare the required Transaction_modes method in the BEGIN or START TRANSACTION to avoid the use of SET TRANSACTION. The
begin has parameters to set the transaction isolation level;
3, the default transaction isolation level for a session can also be set by setting the configuration parameters Default_transaction_isolation and Default_transaction_read_only methods. (actually set SESSION characteristics is just a lengthy equivalent of setting these parameters with set.) This means that the default value can be set through the ALTER DATABASE, in the configuration file, and so on.
that is, the transaction isolation level can also be set to the definition of the database;
------