11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ DATABASE ADMINISTRATION 129LOCK TABLE ... IN lockmode MODE [NOWAIT | WAIT integer]Here’s what the mode parameters nowait and wait mean:• If you want the database to return control to you immediately upon finding that a necessarytable is already locked by other users, specify the nowait option.• You can use the wait parameter to specify the number of seconds the lock table statementcan wait in order to acquire a DML lock. You can set the value of this parameter toany integer value you want—there’s no limit.• If you don’t specify either wait or nowait, the database will wait until the locked table isavailable and then lock it before returning control to you.Invisible IndexesSuppose you have a situation where you have to create a huge index for some special queriesbut don’t want the optimizer to change its query plans based on this index. Furthermore, thesituation may call for dropping and re-creating the index often, which leads to problems becausethe index building takes considerable time. In <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g, you can create an index as aninvisible index, which really means the index won’t be visible to the cost optimizer when it’sfiguring out the execution plans.You can use the invisible index only by specifying the index hint in your SQL statements.In sum, this means you can make selective use of an index, choosing to employ the index onlywhen you want it, not when the optimizer thinks it’s necessary. As far as the optimizer is concerned,the index simply doesn’t exist, unless you reveal its existence!The following situations make the invisible index a handy feature:• You want to test the usefulness of a new index but don’t want to change the optimizer’sexecution plans before you are sure about the usefulness of the new index. You can nowmake the index invisible and have the optimizer generate execution plans without thatindex. If the performance is the same or better, you may decide to drop that index forgood. If, on the other hand, the performance is better with the index, you want to makethat index visible, that is, change it back to a normal index or change its status to visible,as we show later.• You want to use an index for a temporary purpose, such as during an application upgrade,but don’t want the index to be considered by the optimizer subsequently.Although an invisible index is unknown to the cost optimizer unless you cause the index tobe considered by using the index hint, the index continues to be maintained just as any othernormal index. This means when you add new data to the table or modify existing data, theinvisible index will be updated accordingly by the database.Creating an Invisible IndexBy default, all indexes are visible to the optimizer. The new visible|invisible clause of thecreate index statement lets you designate the visibility of an index. If you don’t use this clause,<strong>Oracle</strong> creates the index as a normal index. You can create an invisible index by simply appendingthe keyword invisible at the end of the normal create index statement, as shown here:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!