Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does COMMIT do?

Tags:

sql

oracle

please I want to understand the difference between the folowing two statements:

insert into table_name values (,,,,,);

and

insert into table_name values (,,,,,);
commit;
like image 765
dba2015 Avatar asked Apr 01 '15 07:04

dba2015


People also ask

What is the purpose of COMMIT?

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 Database treats as a single unit.

When should COMMIT be used?

3. COMMIT: COMMIT is a SQL transaction statement that is used to save the changes made by the SQL statements in the previous step permanently in the database.

What happens during COMMIT?

COMMIT commits the current transaction, making its changes permanent. ROLLBACK rolls back the current transaction, canceling its changes. SET autocommit disables or enables the default autocommit mode for the current session.


2 Answers

If you insert data without commit you can select data from database and see it. But other users can't.

It's better to look to sql documentation:

Until you commit a transaction:

You can see any changes you have made during the transaction by querying the modified tables, but other users cannot see the changes. After you commit the transaction, the changes are visible to other users' statements that execute after the commit.

You can roll back (undo) any changes made during the transaction with the ROLLBACK statement (see ROLLBACK.

for example here Oracle Documentation and some info about transactions

like image 199
Ishikawa Yoshi Avatar answered Oct 13 '22 16:10

Ishikawa Yoshi


All the DML (insert, update , delete) to be inserted in the database you have to commit them, like approve that you want to add them in the database. If you dont commit DML statment , it will not be enter in the database.

what is commit ?

Docs.oracle cant describe it better

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 Database treats as a single unit. his statement also erases all savepoints in the transaction and releases transaction locks.

like image 36
Moudiz Avatar answered Oct 13 '22 14:10

Moudiz