Declare: '/TMP' 'Myfile' 'W' 'Look Ma, I''m Writing To A File!!!n'
Declare: '/TMP' 'Myfile' 'W' 'Look Ma, I''m Writing To A File!!!n'
Declare: '/TMP' 'Myfile' 'W' 'Look Ma, I''m Writing To A File!!!n'
12. if you insert a row in a table, then create another table and then say
Rollback.In this case will the row be inserted ?
15. Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure
? How ?
20. Why Create or Replace and not Drop and recreate procedures ?
23. What is the difference between the conventional and direct path loader?
When rows are not stored contiguously, or if rows are split onto more than one
block, performance decreases because these rows require additional block
accesses.
Note that table fragmentation is different from file fragmentation. When a lot
of DML operations are applied on a table, the table will become fragmented
because DML does not release free space from the table below the HWM.
HWM is an indicator of USED BLOCKS in the database. Blocks below the high
water mark (used blocks) have at least once contained data. This data might
have been deleted. Since Oracle knows that blocks beyond the high water mark
don't have data, it only reads blocks up to the high water mark when doing a
full table scan.
Note: Index based queries may not get that much benefited by reorg as compared
to queries which does Full table scan.
How to find Table Fragmentation?
In Oracle schema there are tables which has huge difference in actual size
(size from User_segments) and expected size from user_tables
(Num_rows*avg_row_length (in bytes)). This all is due to fragmentation in the
table or stats for table are not updated into dba_tables.
exec dbms_stats.gather_table_stats('&schema_name','&table_name');
If you find reclaimable space % value more than 20% then we can expect
fragmentation in the table. Suppose, DBA find 50% reclaimable space by above
query, So he can proceed for removing fragmentation.
1. Alter table move (to another tablespace, or same tablespace) and rebuild
indexes:-
(Depends upon the free space available in the tablespace)
2. Export and import the table:- (difficult to implement in production
environment)
3. Shrink command (fron Oracle 10g)
(Shrink command is only applicable for tables which are tablespace with
auto segment space management)
Option: 1 Alter table move (to another tablespace, or same tablespace) and
rebuild indexes:-
------------------------------------------------------------------------------
------------
Collect status of all the indexes on the table:-
----------------------------------------------
We will record Index status at one place, So that we get back them after
completion of this exercise,
OR
STATUS INDEX_NAME
-------- ------------------------------
UNUSABLE INDEX_NAME -------> Here, value in status
field may be valid or unusable.
SQL> alter index <INDEX_NAME> rebuild online; -------> Use this command for
each index
Index altered.
STATUS INDEX_NAME
-------- ------------------------------
VALID INDEX_NAME -------> Here, value in status
field must be valid.
Shrink command:
--------------
Its a new 10g feature to shrink (reorg) the tables (almost) online which can
be used with automatic segment space management.
This command is only applicable for tables which are tablespace with auto
segment space management.
Before using this command, you should have row movement enabled.
Part 2: Reset HWM (No DML can happen. but this is fairly quick, infact goes
unnoticed.)
SQL> alter table <table_name> shrink space;
Table altered.
Search
Translate
27. How can I find all locked objects in Oracle? I need a script to identify
all locked objects.
29. What is the difference between a btree and a bitmap index? I need to
understand the structural differences between a btree and a bitmap index and
understand then to use a b-tree versus a bitmap index on a table column.
30. What is an "explicit" table lock? I understand that Oracle manages all
locks, also I don't understand when I would want to explicitly lock a table?
What is the process of explicitly locking a table?