Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
Oracle 3

Oracle 3

Ratings: (0)|Views: 164 |Likes:
Published by Sachin

More info:

Published by: Sachin on Apr 24, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/26/2010

pdf

text

original

 
A collection of 22 FAQs on Oracle SQL SELECT query statements. Clear answers areprovided with tutorial exercises on starting and ending transactions, committing androlling back transactions, transaction/statement-level read consistency, read committedisolation level, locks and dead locks. Topics included in this FAQ are:1. What Is a Transaction?2. How To Start a New Transaction?3. How To End the Current Transaction?4. How To Create a Testing Table?5. How To Commit the Current Transaction?6. How To Rollback the Current Transaction?7. What Happens to the Current Transaction If a DDL Statement Is Executed?8. What Happens to the Current Transaction If the Session Is Ended?9. What Happens to the Current Transaction If the Session Is Killed?10. How Does Oracle Handle Read Consistency?11. What Is a READ WRITE Transaction?12. What Is a READ ONLY Transaction?13. How To Set a Transaction To Be READ ONLY?14. What Are the Restrictions in a READ ONLY Transaction?15. What Are the General Rules on Data Consistency?16. What Are Transaction Isolation Levels Supported by Oracle?17. What Is a Data Lock?18. How Data Locks Are Respected?19. How To Experiment a Data Lock?20. How To View Existing Locks on the Database?21. What Is a Dead Lock?22. How Oracle Handles Dead Locks?Sample scripts used in this FAQ assumes that you are connected to the server with theHR user account on the default database instance XE. See other FAQ collections on howto connect to the server.
 
Some sample scripts may require database tables created by other samples in thebeginning of the collection.What Is a Transaction?A transaction is a logical unit of work requested by a user to be applied to the databaseobjects. Oracle server introduces the transaction concept to allow users to group one ormore SQL statements into a single transaction, so that the effects of all the SQLstatements in a transaction can be either all committed (applied to the database) or allrolled back (undone from the database).How To Start a New Transaction?There is no SQL statement to explicitly start a new transaction. Oracle server implicitlystarts a new transaction with the following two conditions:
The first executable statement of a new user session will automatically start a newtransaction.
The first executable statement after a previous transaction has been ended willautomatically start a new transaction.How To End the Current Transaction?There are several ways the current transaction can be ended:
Running the COMMIT statement will explicitly end the current transaction.
Running the ROLLBACK statement will explicitly end the current transaction.
Running any DDL statement will implicitly end the current transaction.
Disconnecting a user session will implicitly end the current transaction.
Killing a user session will implicitly end the current transaction.How To Create a Testing Table?If you want to practice DML statements, you should create a testing table as shown in thescript below:
>cd (OracleXE home directory)>.\bin\sqlplus /nologSQL> connect HR/fyicenterConnected.SQL> CREATE TABLE fyi_links (id NUMBER(4) PRIMARY KEY,url VARCHAR2(16) NOT NULL,notes VARCHAR2(16),counts NUMBER(4),created DATE DEFAULT (sysdate));Table created.
 
You should keep this table for to practice other tutorial exercises presented in thiscollection.How To Commit the Current Transaction?If you have used some DML statements updated some data objects, and you want to havethe updates to be permanently recorded in the database, you can use the COMMITstatement. It will make all the database changes made in the current transaction becomepermanent and end the current transaction. The following tutorial exercise shows youhow to use COMMIT statements:
SQL> connect HR/fyicenterSQL> INSERT INTO fyi_links (url, id)2 VALUES ('fyicenter.com', 101);SQL> INSERT INTO fyi_links (url, id)2 VALUES ('centerfyi.com', 110);SQL> SELECT * FROM fyi_links;ID URL NOTES COUNTS CREATED------- ---------------- ---------- ---------- ---------101 fyicenter.com 07-MAY-06110 centerfyi.com 07-MAY-06SQL> COMMIT;Commit complete.
How To Rollback the Current Transaction?If you have used some DML statements updated some data objects, you find a problemwith those updates, and you don't want those updates to be permanently recorded in thedatabase, you can use the ROLLBACK statement. It will remove all the database changesmade in the current transaction and end the current transaction. The following tutorialexercise shows you how to use ROLLBACK statements:
SQL> connect HR/fyicenterSQL> INSERT INTO fyi_links (url, id)2 VALUES ('google.com', 102);SQL> INSERT INTO fyi_links (url, id)3 VALUES ('myspace.com', 103);SQL> SELECT * FROM fyi_links;ID URL NOTES COUNTS CREATED------- ---------------- ---------- ---------- ---------101 fyicenter.com 07-MAY-06110 centerfyi.com 07-MAY-06102 google.com 07-MAY-06103 myspace.com 07-MAY-06

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
Dipankar liked this
ajaadarmaan liked this
balasekhar123 liked this
hello1982 liked this
pallavip10 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->