space used by the database
Hello,
We currently run a nightly report that gives us some information about our customers databases. Some of the info is the total amount of space being used by the database. For this number I query on the sys.dba_data_files. We also try to see what tables have a large number of rows. For this I query num_rows from dba_tables. We started to do a large number of deletes from our database. The problem is were not seeing the amount of space being used decreasing. Is there any thing that we need to do to reclaim that space?
Re: space used by the database
Quote:
Originally posted by theworm
We started to do a large number of deletes from our database. The problem is were not seeing the amount of space being used decreasing. Is there any thing that we need to do to reclaim that space?
The problem is that you have not read the Oracle documentation, and you don't understand how Oracle works.
This is very basic stuff. Go and read the Concepts Guide before your customer figures out that you are not very good at managing oracle databases.
Re: space used by the database
Quote:
Originally posted by theworm
Hello,
We currently run a nightly report that gives us some information about our customers databases. Some of the info is the total amount of space being used by the database. For this number I query on the sys.dba_data_files. We also try to see what tables have a large number of rows. For this I query num_rows from dba_tables. We started to do a large number of deletes from our database. The problem is were not seeing the amount of space being used decreasing. Is there any thing that we need to do to reclaim that space?
OK, here's the story.
When you delete rows from a table in Oracle, the space is not reclaimed. The block that the row was in gets some more free space in it, and if the amount of space used is at or below the PCTUSED setting for that table, then the block is a candidate for new rows to be inserted.
Even if you delete every row from the table, all you have is a lot of empty blocks, but space is still allocated.
To deallocate the space the best method is generally to run ...
"ALTER TABLE MY_TABLE MOVE"
... followed by a rebuild of all indexes on that table (the indexes are rendered invalid by the table move).
Alternatively if you want to find out how much empty space is in a table, you can analyze it and look at various columns in the user_tables or dba_tables view ...
AVG_ROW_LEN, NUM_FREELIST_BLOCKS, AVG_SPACE_FREELIST_BLOCKS, EMPTY_BLOCKS, AVG_SPACE.
These are documented in the Oracle Reference, which you can find (along with the Concepts Guide) at http://tahiti.oracle.com