When does Oracle need a commit

Source: Internet
Author: User
Tags create index sessions

DML languages, such as Update,delete,insert, are required to modify the data in the table Commit;ddl language, such as Create,drop, to change the table structure, do not need to write a commit (because the internal hidden commit);DD l Data definition language: CREATE TABLE creating tables ALTER TABLE modify tables drop table Delete tables truncate TABLE delete all rows in tables CREATE index creates Indexes Drop index drop INDEX when When executing a DDL statement, Oracle commits the current transaction before and after each statement. If the user uses the Insert command to insert a record into the database and executes a DDL statement (such as CreateTable), the data from the Insert command is committed to the database. When the DDL statement execution completes, the DDL statement is automatically committed and cannot be rolled back. DML Data Manipulation Language: Insert records inserted into database update modify database record delete delete database records when the Execute DML command is not committed, it will not be seen by other sessions. Unless a DDL command or DCL command is executed after the DML command, or the user exits the session or terminates the instance, a commit command is automatically issued to make the uncommitted DML command commit. Ddl:data Definition Language (DDL) statements is used to define the database structure or schema. Some examples:create-to CREATE objects in the databasealter-alters the structure of the Databasedrop-delete objects From the Databasetruncate-remove all records to a table, including all spaces allocated for the records is removedcom Ment-add comments to the data dictionaryrename-rename an objectdml:data manipulation Language (DML) statements is use D for managing Data within schema objects. Some Examples:select-retrieve data from the a Databaseinsert-insert data into a tableupdate-updates existing data wi  Thin a Tabledelete-deletes all records from a table, the space for the Records Remainmerge-upsert operation (INSERT or UPDATE) Call-call a PL/SQL or Java subprogramexplain plan-explain access path to DataLock Table-control Concurrencyd Cldata Control Language (DCL) statements. Some examples:grant-gives user ' s access privileges to Databaserevoke-withdraw access privileges given with the GRANT C Ommandtcltransaction Control (TCL) statements is used to manage the changes made by DML statements. It allows statements to being grouped together into logical transactions. Commit-save work donesavepoint-identify a point in a transaction to which can later roll Backrollback-restore da Tabase to original since the last Commitset transaction-change TRANSACTION options like isolation level and what ROLLBAC K segment to use lock concept base database is aA shared resource used by multiple users. When multiple users access data concurrently, in the database, multiple transactions are generated concurrently to access the same data. If the concurrency operation is not controlled, it is possible to read and store incorrect data and compromise the consistency of the database. Locking is a very important technology to realize concurrency control of database. When a transaction makes a request to the system before it operates on a data object, it locks it. After locking, the transaction has some control over the data object, and other transactions cannot update the data object until the transaction releases the lock. There are two basic types of locks in the database: Exclusive lock (Exclusive Locks, X Lock) and shared lock (Share Locks, S lock). When a data object is added to an exclusive lock, other transactions cannot read and modify it. Data objects with shared locks can be read by other transactions, but cannot be modified. The database uses these two basic types of locks to control the concurrency of a database's transactions. The type of lock for an Oracle database depends on the object being protected, the Oracle database lock can be divided into the following categories: DML lock (data locks, lock), which is used to protect the integrity of the data; DDL locks (Dictionary locks, Dictionary locks), The structure used to protect database objects, such as the structure definition of tables, indexes, and internal locks and latches (internal locks and latches), protecting the internal structure of the database. The purpose of a DML lock is to ensure data integrity in the case of concurrency. In Oracle databases, DML locks mainly include TM and TX locks, where TM locks are called table-level locks, and TX locks are called transaction or row-level locks. When Oracle executes DML statements, the system automatically requests a TM-type lock on the table to be operated on. When the TM lock is obtained, the system automatically requests the TX type of lock and resets the lock flag bit of the data row that is actually locked. In this way, checking the compatibility of the TX lock before the transaction is locked, it is necessary to check the compatibility of the TM lock mode and greatly improve the efficiency of the system. TM locks include SS, SX, S, X and other modes, which are represented in the database by 0-6. Different SQL operations produce different types of TM locks. There is only an X lock (exclusive lock) on the data line. In an Oracle database, a TX lock is obtained when a transaction initiates a DML statement for the first time, and the lock remains until the transaction is committed or rolled back. When two or more sessions execute DML statements on the same record on a table, the first session is locked on that record, and the other sessions are waiting. When the first session is committed, the TX lock is released and other sessions can be locked. When a TX lock wait occurs on an Oracle database, failure to handle it often causes the Oracle database to hang or cause a deadlock to occur, resulting in ORA-60 errors. These phenomena can produce veryLarge damage, such as long time not responding, a large number of transaction failures, etc. 

Http://www.cnblogs.com/zhouzangood/articles/5009652.html

When does Oracle need a commit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.