Shrink space of datafile

Oracle 11.1.0.7:
I need to give some space back to the storage. I am trying to figure out what process should I follow to shrink the datafiles and drop the datafiles.
1. Should I first do shrink space on tablespace and then drop few datafiles?
2. How do I know how much space can be shrunk?
3. How do I know if after shrinking which datafiles are ready for drop?
Is there any other better way?

I"ve just gone through a very similar procedure.
First i had to identify the high water mark in each datafile, and then shrink it back to that or just above that value.
NOTE: It's best to do this when your DB is not in use, specifically growing or if it is some of the commands might fail saying that there is data beyond that size.
Now most likely your data is spread across the datafiles in some sort of "optimal" way by oracle, so it's unlikely that you'll be able to get any "clean" datafiles that you can just drop.
So what i did was to create a new tablespace big enough to hold the objects, MOVED the tables and REBUILT the indexes in the new TS.
Now one option here is to just keep the new TS's and drop the old ones, if needed you can even rename your tablespace (10g and above)
ALTER TABLESPACE old_ts RENAME TO new_ts;
However, you must follow the rules when renaming a tablespace (also need to separetly rename the df if you want to keep your naming standard) :
You cannot rename the SYSTEM or SYSAUX tablespaces.
You cannot rename an offline tablespace.
You cannot rename a tablespace that contains offline datafiles.
Here we wanted to keep the file names locations so i ended up copying everything back into the originals, but before i did that , i could querried dba_segments to get the minimum size required, and I then I shrunk and dropped the datafiles in the original TS as appropriate.
To get the hight water mark, i used this script :
SELECT 'ALTER DATABASE DATAFILE ''' || FILE_NAME || ''' RESIZE ' || HWMM || ';' CL_DYN_SQL
FROM (
SELECT DF.FILE# FILE_ID, DF.NAME FILE_NAME, NVL(DFD.MAX_BLOCK_COUNT,1)*DF.BLOCK_SIZE HWM,
DECODE(SIGN((1024)-(CEIL(NVL(DFD.MAX_BLOCK_COUNT,1)*DF.BLOCK_SIZE/(1024*1024)))),
          1,1024, CEIL(NVL(DFD.MAX_BLOCK_COUNT,1)*DF.BLOCK_SIZE/(1024*1024))) || 'M' HWMM,
          DF.BYTES
FROM V$DATAFILE DF, V$TABLESPACE TS,
SELECT FILE_ID, MAX(BLOCK_ID+BLOCKS-1) MAX_BLOCK_COUNT
          FROM DBA_EXTENTS DE
          WHERE DE.TABLESPACE_NAME IN ('TS_D', 'TS_I')
          GROUP BY FILE_ID
) DFD          
WHERE DF.FILE# = DFD.FILE_ID (+)
AND DF.TS# = TS.TS#
AND TS.NAME IN ('TS_D', 'TS_I')
WHERE HWM < BYTES
ORDER BY 1;

Similar Messages

  • Alter SHRINK SPACE in oracle 10g

    Hello,
    My table PRICE_T table gets deleted and inserted almost 50 million records everyday.
    Now it takes too much time to perform this operation because of TABLE fragmented.
    i can use "CREATE table as select” option to remove fragmentation from table.
    but i dont want to use this option.
    so i hv tried ALTER TABLE SHRINK SPACE as i m using ORACLE 10g
    alter table price_t enable row movement;
    alter table price_t shrink space
    alter table price_t disable row movement;
    and i have applied following query to check table gets remove free space but still having free space after applying ALTER SPACE COMMAND
    select table_name,round((blocks*8),2)||'kb' "size1",round((num_rows*avg_row_len/1024),2)||'kb' "size"
    from DBA_tables
    where table_name = 'PRICE_T';
    Tablespace in PRICE_T table fall into is SEGMENT SPACE MANAGEMENT AUTO
    please help me to remove fragmentation from table using SHRINK command.
    Thanks.

    Now it takes too much time to perform this operation because of TABLE fragmented.How do you define "fragmented"?
    Why do you believe that your table is fragmented?
    Why do you believe that the fragmentation is causing performance problems?
    select table_name,
           round((blocks*8),2)||'kb' "size1",
           round((num_rows*avg_row_len/1024),2)||'kb' "size"
      from DBA_tables
    where table_name = 'PRICE_T'; - What is the output of this query before and after you shrink the table?
    - Are your statistics up to date? NUM_ROWS, BLOCKS and AVG_ROW_LENGTH provide information to the optimizer-- they are estimates gathered when object statistics are gathered. They are not maintained by Oracle in real time and may be substantially out of date.
    - I don't see any attempt to account in this query for overhead like PCTFREE.
    - Is there a reason that you aren't using the DBMS_SPACE package? This query seems highly suspect.
    Justin

  • Is alter table shrink space a logged operation?

    Hello -
    I am running alter table xxxxxx shrink space. I have a few questions:
    1. Is this a logged operation? Oracle handles this interanally as insert/delete operations, but I am not seeing more arch logs being generated.
    2. If I stop in the middle of the shrink process, can Oracle resume where it left off?
    3. How can I monitor the progress of the shrink operation? I am not seeing the sid, serial# in v$session_longops.
    Any help is much appreciated!
    Thanks,
    mike

    I'm not sure that you will be able to "monitor" it.
    You could test using dbms_space to see if it shows any changes will the shrink is in progresss.
    One other way would be to watch V$TRANSACTION USED_UREC (which will reflect counts for rows and index entries) to see USED_UREC approaching the expected number of table+index entries being rebuilt.
    Hemant K Chitale
    http://hemantoracledba.blogspot.com

  • Find the used space in datafile on any specific date

    Hi,
    We have a datafile created on 2-11-2009.
    I wish to find the used space in that datafile on 13-12-2009.
    From v$datafile and dba_data_files from the "BYTES" column it wld give me the current used space in the datafile.
    But how to find the used space in datafile on any specific date.
    Thanks.

    Hello,
    It depends on your Oracle release, starting with Oracle 10.1, you have the View dba_hist_tpspc_space_usage which may give you an history of the space used by the Tablespaces:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_3195.htm#I1023456
    You may have to pay for specific license to be allowed to access to this View which belongs to AWR (Automatic Workload Repository).
    Hope this help.
    Best regards,
    Jean-Valentin

  • How to find free space in datafiles of perticular schema?

    hai,
    whats the query to find out free space in datafiles and index files related free space for perticular schmea?
    Regards
    dba

    There are lots of scripts available on Metalink which report free space in tablespaces/datafiles.
    Note: 1019999.6 - Script: To List Tablespace, Datafiles and Free Space
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=1019999.6
    Note: 145531.1 - How to Determine Which Tablespaces Do Not Have Enough Free Space
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=145531.1

  • Impact to production if I shrink space on table...

    Hello experts.
    I am running Oracle 11.2 and saw in OEM that I have a table that is candidate for shrinking space.
    According to OEM, I can gain 5G by shrinking the table.
    The table is 16G, so if I shrink the table, then it should reduce to approx. 11G, right?
    This table is the primary table used by our application, so impact to production is very important.
    Okay, so I'm wondering what the impact to production is on the table while I shrink the space on the table.
    I am testing it now in my test environment.
    First, I found I had a function based index which has to be dropped before I can shrink the table.
    So I ran dbms_metadata to get the syntax to recreate the FBI, then dropped the FBI.
    Next, i ran alter table owner.tablename enable row movement;
    Then, I ran alter table owner.tablename shrink space cascade;
    While I am running the shrink table command, I opened another session and I queried the table and even did updates on the table.
    I was quite surprised in that the table is not locked and is still accessible for update and select statements.
    In fact, I do not see any noticeable impact by the shrink table command.
    Obviously, I am not in the production environment with hundreds of concurrent users, but my question is what kind of impact should I expect to see if I do this in production with people hitting this table? (No, this is not an IOT.)
    Any ideas?
    Edited by: 974632 on Feb 19, 2013 5:54 AM
    NOTE: The table shrink command took: Elapsed: 00:43:17.19
    Recreating the function based index took: Elapsed: 00:00:28.80

    Uwe Hesse wrote:
    What you observe is standard behavior.
    A potential impact comes from the massive internal DELETE & INSERT during the shrink operation.
    Will generate lots of redo & undo therefore.
    That's is not necessarily a problem, though.
    Kind regards
    Uwe Hesse
    "Don't believe it, test it!"
    http://uhesse.com
    Uwe,
    Correct me if I'm wrong, but my thought on reading the OP is that he could very well see a performance degradation during the shrink operation, but I'd also expect to see some overall improvement after the operation due to a large decrease in the number of blocks that would have to be scanned during any FTS, and possibly some cascading of that effect back through any indexes on that table.

  • Alter table modify lob shrink space hangs despite ddl_lock_timeout

    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    The following command hangs despite session parameter ddl_lock_timeout being set to 0:
    alter table <table> modify lob (<column>) (shrink space);
    Data type of <column> is CLOB. In another session a transaction on <table> is open, with a simple update on a different (non-LOB) column.
    Looks like a bug to me, but have no access to metalink for confirmation/SR submission and would appreciate any comments/help on this issue.

    From Oracle 11 documentation ( http://docs.oracle.com/cd/B28359_01/server.111/b28310/schema003.htm#CBBBIADA )
    "Segment shrink is an online, in-place operation. DML operations and queries can be issued during the data movement phase of segment shrink."
    Simon

  • What do I do after shrink space

    Hi,
    Do I need to do anything after shrink space?
    After I shrink the tables and indexes spaces, I saw the significent space saving. question is do I need to re-collect statistic after shrink? would query plans changed after shink space? if I have outlines defined to freeze query plan, should I re-generated outlines?
    anything else should I consider after shrink space?
    Thank you

    asanga wrote:
    no need to do anything for outlinesThank you !. so, this would imply that query plan won't be changed after shrink? is my understanding correct?

  • SHRINK SPACE - How do you monitor progress?

    Does anyone know how to monitor the progress of a SHRINK SPACE command ?
    Session_Longops view shows nothing for that SID.

    you may customize the columns selected or the filters of the below query and monitor who is doing what, and if necessary you may start event 10046 level 8 trace - http://tonguc.wordpress.com/2006/12/30/introduction-to-oracle-trace-utulity-and-understanding-the-fundamental-performance-equation/
    SELECT sq.sql_text,
           se.status,
           se.username,
           se.osuser,
           se.terminal,
           se.machine,
           'ALTER SYSTEM KILL SESSION ''' || se.sid || ', ' || se.serial# ||
           ''' IMMEDIATE ;',
           se.sid,
           se.serial#,
           pr.spid,
           se.saddr,
           se.schemaname,
           se.program,
           se.logon_time,
           sq.hash_value,
           sq.address,
           sq.buffer_gets,
           sq.disk_reads,
           sq.executions,
           sq.fetches,
           sq.rows_processed,
           io.block_gets,
           io.consistent_gets,
           io.physical_reads,
           io.block_changes,
           io.consistent_changes,
           se.module,
           se.action,
           se.client_info,
           sw.event,
           sw.p1text,
           sw.p1,
           sw.p2text,
           sw.p2,
           pr.pga_used_mem,
           pr.pga_alloc_mem,
           pr.pga_freeable_mem,
           pr.pga_max_mem,
           'exec dbms_support.start_trace_in_session(' || se.sid || ', ' || se.serial# || ', ' ||
           'waits => TRUE' || ', ' || 'binds => TRUE);',
           'exec dbms_support.stop_trace_in_session(' || se.sid || ', ' || se.serial# || ');'
      FROM v$session se, v$sqlarea sq, v$process pr, v$session_wait sw, v$sess_io io
    WHERE status IN ('ACTIVE', 'KILLED', ' INACTIVE', ' CACHED', ' SNIPED')
       AND TYPE = 'USER'
       AND se.sql_hash_value = sq.hash_value(+)
       AND se.sql_address = sq.address(+)
       AND se.paddr = pr.addr
       AND se.sid = sw.sid
       AND se.sid = io.sid
    ORDER BY sq.sql_text, se.username, se.schemaname, se.osuser, se.program, se.sid

  • Shrink space statement can support parallel ?

    Hi there
    I would like to know whether shrink space statement support parallel. my database size is around 1300 GB and it is production database.
    My database is oracle 10 R2 (10.2.0.3)
    Regards
    Jewel

    Hi sb92075
    I am dishearten to your response. This kind of reply is not expected from such as reputed forum.
    I know better than you about oracle manual. Oracle manual is vast , usually we place our question (request) in a forum to get quick response.
    It means you don't want to share your knowledge.
    Jewel

  • Script for Free Space in Datafiles

    Hi
    Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
    1)Is dba_Free_Space an exact indicator of how much space is available in a file.
    2) What is the significance of using blocks in vs using bytes.
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    Thanks in advance for you help.
    Script for checking backwards for free space at end of file
    REM Script is meant for Oracle version 9 and higher
    REM -----------------------------------------------
    set serveroutput on
    exec dbms_output.enable(1000000);
    declare
    cursor c_dbfile is
    select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
    from dba_data_files f,
    dba_tablespaces t
    where f.tablespace_name = t.tablespace_name
    and t.status = 'ONLINE'
    order by f.tablespace_name,f.file_id;
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    /* variables to check settings/values */
    dummy number;
    checkval varchar2(10);
    block_correction number;
    /* running variable to show (possible) end-of-file */
    file_min_block number;
    /* variables to check if recycle_bin is on and if extent as checked is in ... */
    recycle_bin boolean:=false;
    extent_in_recycle_bin boolean;
    /* exception handler needed for non-existing tables note:344940.1 */
    sqlstr varchar2(100);
    table_does_not_exist exception;
    pragma exception_init(table_does_not_exist,-942);
    begin
    /* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
    begin
    select value into checkval from v$parameter where name = 'recyclebin';
    if checkval = 'on'
    then
    recycle_bin := true;
    end if;
    exception
    when no_data_found
    then
    recycle_bin := false;
    end;
    /* main loop */
    for c_file in c_dbfile
    loop
    /* initialization of loop variables */
    dummy :=0;
    extent_in_recycle_bin := false;
    file_min_block := c_file.blocks;
    begin
    <<check_free>>
    for c_free in c_freespace(c_file.file_id)
    loop
    /* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
    block_correction := (0-mod(c_free.max_block,2));
    if file_min_block = c_free.max_block+block_correction
    then
    /* free extent is at end so file can be resized */
    file_min_block := c_free.block_id;
    else
    /* no more free extent at end of file, file cannot be further resized */
    exit check_free;
    end if;
    end loop;
    end;
    /* check if file can be resized, minimal size of file 16 blocks */
    if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
    then
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('cannot be resized no free extents found');
    dbms_output.put_line('.');
    else
    /* file needs minimal no of blocks which does vary over versions */
    if file_min_block < 16
    then
    file_min_block := 16;
    end if;
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
    /* below is only true if recyclebin is on */
    if recycle_bin
    then
    begin
    sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
    execute immediate sqlstr into dummy;
    if dummy > 0
    then
    dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
    dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
    dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
    end if;
    exception
    when no_data_found
    then null;
    when table_does_not_exist
    then null;
    end;
    end if;
    dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
    dbms_output.put_line('.');
    end if;
    end loop;
    end;
    Example output for Oracle version 9 and higher:
    Tablespace: TEST Datafile: /oradata/v112/test01.dbf
    cannot be resized no free extents found
    Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
    current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
    SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
    Tablespace: USERS Datafile: /oradata/v112/users01.dbf
    current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
    Extents found in recyclebin for above file/tablespace
    Implying that purge of recyclebin might be needed in order to resize
    SQL> purge tablespace USERS;
    SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K

    Hi
    Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
    1)Is dba_Free_Space an exact indicator of how much space is available in a file.
    2) What is the significance of using blocks in vs using bytes.
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    Thanks in advance for you help.
    Script for checking backwards for free space at end of file
    REM Script is meant for Oracle version 9 and higher
    REM -----------------------------------------------
    set serveroutput on
    exec dbms_output.enable(1000000);
    declare
    cursor c_dbfile is
    select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
    from dba_data_files f,
    dba_tablespaces t
    where f.tablespace_name = t.tablespace_name
    and t.status = 'ONLINE'
    order by f.tablespace_name,f.file_id;
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    /* variables to check settings/values */
    dummy number;
    checkval varchar2(10);
    block_correction number;
    /* running variable to show (possible) end-of-file */
    file_min_block number;
    /* variables to check if recycle_bin is on and if extent as checked is in ... */
    recycle_bin boolean:=false;
    extent_in_recycle_bin boolean;
    /* exception handler needed for non-existing tables note:344940.1 */
    sqlstr varchar2(100);
    table_does_not_exist exception;
    pragma exception_init(table_does_not_exist,-942);
    begin
    /* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
    begin
    select value into checkval from v$parameter where name = 'recyclebin';
    if checkval = 'on'
    then
    recycle_bin := true;
    end if;
    exception
    when no_data_found
    then
    recycle_bin := false;
    end;
    /* main loop */
    for c_file in c_dbfile
    loop
    /* initialization of loop variables */
    dummy :=0;
    extent_in_recycle_bin := false;
    file_min_block := c_file.blocks;
    begin
    <<check_free>>
    for c_free in c_freespace(c_file.file_id)
    loop
    /* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
    block_correction := (0-mod(c_free.max_block,2));
    if file_min_block = c_free.max_block+block_correction
    then
    /* free extent is at end so file can be resized */
    file_min_block := c_free.block_id;
    else
    /* no more free extent at end of file, file cannot be further resized */
    exit check_free;
    end if;
    end loop;
    end;
    /* check if file can be resized, minimal size of file 16 blocks */
    if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
    then
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('cannot be resized no free extents found');
    dbms_output.put_line('.');
    else
    /* file needs minimal no of blocks which does vary over versions */
    if file_min_block < 16
    then
    file_min_block := 16;
    end if;
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
    /* below is only true if recyclebin is on */
    if recycle_bin
    then
    begin
    sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
    execute immediate sqlstr into dummy;
    if dummy > 0
    then
    dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
    dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
    dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
    end if;
    exception
    when no_data_found
    then null;
    when table_does_not_exist
    then null;
    end;
    end if;
    dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
    dbms_output.put_line('.');
    end if;
    end loop;
    end;
    Example output for Oracle version 9 and higher:
    Tablespace: TEST Datafile: /oradata/v112/test01.dbf
    cannot be resized no free extents found
    Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
    current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
    SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
    Tablespace: USERS Datafile: /oradata/v112/users01.dbf
    current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
    Extents found in recyclebin for above file/tablespace
    Implying that purge of recyclebin might be needed in order to resize
    SQL> purge tablespace USERS;
    SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K

  • Oracle 11g - How to repair block corruption(on free space) in datafile

    Hi,
    I have a tablesopace with 3 datafiles, out of which one datafile has corrupted block. But no objects or data is affected as the corrupted block os in free space. This was shown in the alert logs.
    Please see below the details:
    Wed Apr 06 15:30:04 2011
    SMON: Restarting fast_start parallel rollback
    SMON: ignoring slave err,downgrading to serial rollback
    ORACLE Instance geooap (pid = 12) - Error 1578 encountered while recovering transaction (10, 6) on object 149755.
    Errors in file f:\oracle11g\diag\rdbms\geooap\geooap\trace\geooap_smon_5540.trc:
    ORA-01578: ORACLE data block corrupted (file # 7, block # 54053)
    ORA-01110: data file 7: 'F:\ORACLE11G\ORADATA\GEOOAP\ORDER_DATA_01.DBF'
    GEOAP:
    Fri Apr 01 14:57:48 2011
    Errors in file f:\oracle11g\diag\rdbms\geop\geop\trace\geop_arc1_2156.trc:
    ORA-00235: control file read without a lock inconsistent due to concurrent update
    Fri Apr 01 14:57:58 2011
    ================================================================
    The corruption is being reported in a free space block of the ORDER_DATA_01.DBF.
    I’ve checked all the tables (and indexes) in this tablespace and none report corruption.
    =====================================================Is there any action I need to take to remove corruption at this point?It is not affected any operation on the database yet.
    What is the best way to do get rid of the corrupt block, without dropping and rebuillding the full tablespace(which is around 6 GB -total of 3 datafiles)
    Thanks a lot

    Can RMAN recover the datablock from this cold backup(which is a week old, the data file was not corrupted then) ?Please note that to do the recovery, you would need the backup and the archivelog files since the backup. Think about what you are asking to do. Its a single block whose recovery you are asking from a week old backup which obviously would be on an much older SCN compared to the rest of the database. How would you make that block consistent with the rest of the datafile. If you don't have archivelog in that db whose block is corrupted, you may forget that block and any data that it might ever had. Also, please read the documentation about the block recovery which explains the requirements very clearly,
    http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmblock.htm#BRADV89784
    From the above link, 1st point,
    The target database must run in ARCHIVELOG mode and be open or mounted with a current control file.HTH
    Aman....

  • ORA-1653: unable to extend table - but enough space for datafile

    We encountered this problem in one of our database Oracle Database 10g Release 10.2.0.4.0
    We have all datafiles in all tablespaces specified with MAXSIZE and AUTOEXTEND ON. But last week database could not extend table size
    Wed Dec  8 18:25:04 2013
    ORA-1653: unable to extend table PCS.T0102 by 128 in                 tablespace PCS_DATA
    ORA-1653: unable to extend table PCS.T0102 by 8192 in                tablespace PCS_DATA
    Wed Dec  8 18:25:04 2013
    ORA-1653: unable to extend table PCS.T0102 by 128 in                 tablespace PCS_DATA
    ORA-1653: unable to extend table PCS.T0102 by 8192 in                tablespace PCS_DATA
    Wed Dec  8 18:25:04 2013
    ORA-1653: unable to extend table PCS.T0102 by 128 in                 tablespace PCS_DATA
    ORA-1653: unable to extend table PCS.T0102 by 8192 in                tablespace PCS_DATA
    Datafile was created as ... DATAFILE '/u01/oradata/PCSDB/PCS_DATA01.DBF' AUTOEXTEND ON  NEXT 50M MAXSIZE 31744M
    Datafile PCS_DATA01.DBF had only 1GB size. Maximum size is 31GB but database did not want to extend this datafile.
    We used temporary solution and we added new datafile to same tablespace. After that database and our application started to work correctly.
    There is enough free space for database datafiles.
    Do you have some ideas where could be our problem and what should we check?
    Thanks

    ShivendraNarainNirala wrote:
    Hi ,
    Here i am sharing one example.
    SQL> select owner,table_name,blocks,num_rows,avg_row_len,round(((blocks*8/1024)),2)||'MB' "TOTAL_SIZE",
      2   round((num_rows*avg_row_len/1024/1024),2)||'Mb' "ACTUAL_SIZE",
      3   round(((blocks*8/1024)-(num_rows*avg_row_len/1024/1024)),2) ||'MB' "FRAGMENTED_SPACE"
      4   from dba_tables where owner in('DWH_SCHEMA1','RM_SCHEMA_DDB','RM_SCHEMA') and round(((blocks*8/1024)-(num_rows*avg_row_len/1024/1024)),2) > 10 ORDER BY FRAGMENTED_SPACE;
    OWNER           TABLE_NAME                        BLOCKS   NUM_ROWS AVG_ROW_LEN TOTAL_SIZE           ACTUAL_SIZE          FRAGMENTED_SPACE
    DWH_SCHEMA1     FP_DATA_WLS                        14950     168507          25 116.8MB              4.02Mb               112.78MB
    SQL> select tablespace_name from dba_segments where segment_name='FP_DATA_WLS' and owner='DWH_SCHEMA1';
    TABLESPACE_NAME
    DWH_TX_DWH_DATA
    SELECT /* + RULE */  df.tablespace_name "Tablespace",
           df.bytes / (1024 * 1024) "Size (MB)",
           SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
           Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
           Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
      FROM dba_free_space fs,
           (SELECT tablespace_name,SUM(bytes) bytes
              FROM dba_data_files
             GROUP BY tablespace_name) df
    WHERE fs.tablespace_name   = df.tablespace_name
    GROUP BY df.tablespace_name,df.bytes
    UNION ALL
    SELECT /* + RULE */ df.tablespace_name tspace,
           fs.bytes / (1024 * 1024),
           SUM(df.bytes_free) / (1024 * 1024),
           Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
           Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
      FROM dba_temp_files fs,
           (SELECT tablespace_name,bytes_free,bytes_used
              FROM v$temp_space_header
             GROUP BY tablespace_name,bytes_free,bytes_used) df
    WHERE fs.tablespace_name   = df.tablespace_name
    GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
    ORDER BY 4 DESC;
    set lines 1000
    col FILE_NAME format a60
    SELECT SUBSTR (df.NAME, 1, 60) file_name, df.bytes / 1024 / 1024 allocated_mb,
    ((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
    used_mb,
    NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
    FROM v$datafile df, dba_free_space dfs
    WHERE df.file# = dfs.file_id(+)
    GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
    ORDER BY file_name;
    Tablespace                      Size (MB)  Free (MB)     % Free     % Used
    DWH_TX_DWH_DATA                     11456       8298         72         28
    FILE_NAME                                                    ALLOCATED_MB    USED_MB FREE_SPACE_MB
    /data1/FPDIAV1B/dwh_tx_dwh_data1.dbf                                 1216       1216             0
    /data1/FPDIAV1B/dwh_tx_dwh_data2.dbf                                10240       1942          8298
    SQL> alter database datafile '/data1/FPDIAV1B/dwh_tx_dwh_data2.dbf' resize 5G;
    alter database datafile '/data1/FPDIAV1B/dwh_tx_dwh_data2.dbf' resize 5G
    ERROR at line 1:
    ORA-03297: file contains used data beyond requested RESIZE value
    Although , we did moved the tables into another TB , but it doesn't resolve the problem unless we take export and drop the tablespace aand again import it .We also used space adviser but in vain .
    As far as metrics and measurement is concerned , as per my experience its based on blocks which is sparse in nature related to HWM in the tablespace.
    when it comes to partitions , just to remove fragmentation by moving their partitions doesn't help  .
    Apart from that much has been written about it by Oracle Guru like you .
    warm regards
    Shivendra Narain Nirala
    how does free space differ from fragmented space?
    is all free space considered by you to be fragmented?
    "num_rows*avg_row_len" provides useful result only if statistics are current & accurate.

  • Reclaim free space in datafiles

    Hello:
    I have taken over management of one of our test servers with Oracle 9i on Windows2000 and have noticed that there are two files that are much larger than the space that is actually being used:
    D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF - 17964M - (Used 1,542M)
    D:\ORACLE\ORADATA\ORCL\DATA01.DBF - 12511M - (Used 243M)
    How can I reclaim all of this unused space?

    Remember it is always best to reclaim space by moving all the objects to another tablespace and reclaiming all space. This will free up space within the tables and indexes as well.
    I use the following script to generate the commands for me:
    resizea.sql:
    drop table alan99;
    set pages 50
    create table alan99 as
    select max(block_id+blocks) block_id,file_id from dba_extents
    group by file_id;
    column tablespace_name format a15
    column pct format 999.99
    set wrap off
    set lines 120
    set trunc off
    column file_id format 999
    spool resizea.lst
    select b.bytes/1024/1024-a.bytes/1024/1024 CURRENT_meg,
    a.file_id,a.tablespace_Name,'alter database datafile '''||b.file_name||''' resize '
    ||trunc(c.block_id*8192/1024/1024+1)||'m;'
    from dba_free_space a,dba_data_files b, alan99 c
    where a.file_id=b.file_id
    and a.block_id=c.block_id and a.file_id=c.file_id
    order by current_meg;
    set termout off
    drop table alan99;
    set termout on
    spool off
    select 'Your output has been saved as resizea.lst' from dual;
    A script that will tell you what is inside is:
    column owner format a30
    column object format a30
    set lines 120
    set wrap off
    set trunc off
    set pages 50
    set feedback on
    column file_id format 999
    select     /*+ Rule */     'free space' owner     /*"owner" of free space*/
    ,          ' ' object          /*blank object name*/
    ,          file_id                    /*file id for the extent header*/
    ,          block_id               /*block id for the extent header*/
    ,          blocks                    /*length of the extent, in blocks*/
    from          dba_free_space
    where          file_id=&1
    union
    select     /*+ Rule */ substr(owner,1,20)||' '||substr(segment_type,1,9) /*owner name (first 20 chars)*/
    ,          substr(segment_name,1,32)||'.'||partition_name     /*segment name*/
    ,          file_id                    /*file id for the extent header*/
    ,          block_id               /*block id for the extent header*/
    ,          blocks                    /*length of the extent, in blocks*/
    from           dba_extents
    where          file_id=&1
    order by     3,4
    /

  • Shrink space (em)


    when I run segment advısor for specıfıc table shrınk ıs advısed.
    Than I make a shrınk.
    Than I run segment advısor for the same table agaın and agaın shrınk ıs advısed.
    and I shrınk ıt agaın and agaın and agaın.
    I notıce that everytıme I shrınk for the same table, reclaımable space and alocatted space decrease.
    why shrinking several times??

    actually, I do ıt by usıng enterprıse manager:
    I run segment advısor( ıt says shrınk ıs needed)
    than I shrınk ıt
    and run agaın segment advısor but ıt says agaın
    shrınk ıs needed
    and so onTo quote the Huffington Post (first time for everything I suppose) then you need to get better advisors!
    More seriously this is probably a great example of the need to delegate just the technical detail to EM whilst allowing the DBA to exercise his/her judgement. If the advisor didn't exist you might do the manual equivalent once a month (say) - it's highly unlikely that you'd immediately start the analysis all over again if it was a manual task. Why not, well first you'd want to see how the implementation actually worked in practice for a while and second it would require a lot lot more effort (which equals cost). So even if you buy into the idea of automating the selection of segments to shrink on a regular basis - it seems a little odd to implement the recommendations and then immediately redo the selection process.
    Personally I'm not convinced by the need for this advisor in the first place - in my experience large amounts of space only really tends to be wasted by Oracle when large deletes or direct path inserts happen, and on those occassions you really ought to be aware of the likely side effects when carrying out the operations that created the space in the first place.
    Niall Litchfield
    http://www.orawin.info/

Maybe you are looking for

  • Total Problem

    Hi All, I have upgraded a report from 6i to 10g, its a customer statement report that shows the customer transaction their running total, Carried forward total at end of page, Brought forward total, and then finally the end total. But in my report th

  • Object autorization P_ABAP in RPAPRT09 for trx. PBA7

    Hello, I have problems with PBA7, this activating the authorization object P_ABAP in LRP, but in LRQ  doesn't, and the rol in LRP and LRQ is the same ones for the user.  The value that requires is (2) but the rol has the value (1).  The program is RP

  • Can I use SPEL instead of PPR

    Dear, I have two message text input fields on a page. My requirement is - the second one should render ONLY IF a user enters XYZ in the first field. From looking at posts related to SPEL I gather that I need to use PPR to satisfy this requirement bec

  • How do i change the number on imassage

    how do i change the number on imassage?

  • Crosstab specified sort order

    Post Author: Jan_Hauptmann CA Forum: Crystal Reports Hi,I am quite new to Crystal Report (XI), especially crosstabs. Currently I am trying to create a crosstabwhere selected customer are shown on the top of the crosstab and all not selected to be cou