Space saved by truncating a table

Hi,
Can anyone please let me know how to check ,how much disk storage will be saved by truncating a particular table
Thanks,
Kr

Assuming you intend on releasing the space, i.e. you're doing a TRUNCATE TABLE table_name DROP STORAGE rather than REUSE STORAGE, all the data in the table will be removed. So you just need to figure out how much space is allocated to the table and all its dependent objects. Assuming that you just have a table with indexes and no LOBs or other "interesting" wrinkles
SELECT SUM(bytes)
  FROM user_segments
WHERE segment_name = <<table_name>>
   OR segment_name IN (
      SELECT index_name
        FROM user_indexes
       WHERE table_name = <<table_name>>
      )Justin

Similar Messages

  • Release of space after delete/truncate table

    Hello,
    How does release of space after delete/truncate table works? Is the space used before deletion released once delete is complete or not? Will I see the space occupied by deleted table as free in dba_segments or will I need to reorganize the table (drop and recreate again?). Reason why I am asking is that I can see table with 0 rows, but in dba_segment I can see it is occupying few gigabytes....
    Thank you

    Here is a little illustration for you;
    SQL> conn ogan/password
    Connected.
    SQL> create table ogan_deneme as select * from all_objects;
    Table created.
    SQL> select count(*) from ogan_deneme;
      COUNT(*)
        228470
    SQL> set line 1000
    SQL> set pagesize 1000
    SQL> select * from dba_segments where owner='OGAN';
    OWNER    SEGMENT_NAME        PARTITION_NAME           SEGMENT_TYPE       TABLESPACE_NAME                HEADER_FILE HEADER_BLOCK      BYTES     BLOCKS    EXTENTS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS RELATIVE_FNO BUFFER_
    OGAN      OGAN_DENEME          TABLE              SYSTEM                                 854       319981   *30408704*       *1856*         *44*          65536                       1  2147483645                       1               1          854 DEFAULT
    SQL> truncate table ogan_deneme;
    Table truncated.
    SQL> select * from dba_segments where owner='OGAN';
    OWNER    SEGMENT_NAME        PARTITION_NAME           SEGMENT_TYPE       TABLESPACE_NAME                HEADER_FILE HEADER_BLOCK      BYTES     BLOCKS    EXTENTS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS RELATIVE_FNO BUFFER_
    OGAN      OGAN_DENEME           TABLE              SYSTEM                                 854       319981      *65536*          *4*          *1*          65536                       1  2147483645                       1               1          854 DEFAULT
    SQL>Hope it Helps,
    Ogan

  • Space is not released after truncating the table

    Team,
    We have a table of size 550gigs in size and we truncated the table , truncated sucessfully but space is not released in os level, what action we can take to release the space and this table has only one row and contains the binary data.
    Thanks
    PGR

    Team,
    We have a table of size 550gigs in size and we truncated the table , truncated sucessfully but space is not released in os level, what action we can take to release the space and this table has only one row and contains the binary data.
    Thanks
    PGR
    Hello,
    Yes space wont be released immediately .If large extents are in picture which I assume is your case it goes into deferred drop a background process which will execute after some time( time may vary).See below link for details.
    As per BOL if extents are more than 128 it goes in deferred drop.
    http://msdn.microsoft.com/en-us/library/ms177495.aspx
    You should wait for some time .keep checking the free space
    Below discussion will surely help you in understanding.See Jonathan's reply
    http://social.msdn.microsoft.com/Forums/en-US/4aa2537e-246b-4bfe-818d-3482531d9149/sql-server-2005-massive-400gb-table-dropped-space-not-released
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • How will check the space taken by a single table in a tablespace ?

    How will check the space taken by a single table in a tablespace ?
    dba_segments is giving the same values even if I truncate the table?
    Pls reply

    I need to know how can we find out the size of the table in the tablespace.use user_segments (bytes) column.
    How much bytes it has taken ?value from user_segments, bytes column
    If u delete records will the space be used for another table in same tablespace?No, it keep the space in the same table for future usage.
    How can we free that space ?truncate or drop the table and reduce the size from tablespace, if you want to reclaim the space from the tablespace, OS level.
    Jaffar

  • Truncate DEF$ tables

    Hi,
    What is the impact if I remove / Truncate below tables as this tables are consuming log of space.
    Will the replication process work fine after truncating/ dropping the below tables.
    system.DEF$_CALLDEST;
    system.DEF$_DEFAULTDEST;
    system.DEF$_ERROR;
    system.DEF$_ORIGIN;
    system.REPCAT$_REPSCHEMA;
    system.DEF$_DESTINATION;
    system.DEF$_LOB;
    system.DEF$_TEMP$LOB;
    system.DEF$_PUSHED_TRANSACTIONS;
    system.DEF$_AQCALL;
    system.DEF$_AQERROR;
    Regards,
    Atif Iqbal.

    Do you not have the PURGE job scheduled to run ?
    You should not be manually truncating these tables.
    Hemant K Chitale

  • Truncating a table from inside an application

    Hi all,
    Got a new problem to tackle. I am creating an application to calculate a very complex production bonus based on alot of different variables...
    I am working through retrieving all the data and created an apex temp table called site_bonus. I dump all the retireved values I get from Oracle for attendance, SIT data on discipline etc into the temp table as a count of number of occureneces to start the calculation of the bonus factors - here's the gotcha.....
    Prior to dumping the new run data into the temp table I want to truncate the table to remove anyprevious run data so that I dont get duplicate records cuased by a previous run. I created an on demand application process that basically does the following:
    truncate table "SITE_BONUS" /
    ( I basically copied it right from SQL workshop inside apex,by retrieving the SQL fromthe table truncate process where it works....
    When I run it anywhere inside my page as an on demand process It fails with the following error:
    ORA-06550: line 1, column 16: PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: := . ( @ % ; The symbol ":= was inserted before "TABLE" to continue.
    Error
    OK
    I have tried it as a plsql process, an on demand process....and I get teh same error from any page inside my app and I cant figure out why I can do this from SQL worksop but cant call it from a page within my app.....
    Any ideas?
    Edited by: DSULLIVAN on Oct 28, 2009 3:13 PM - I corrected the typo

    You are trying : trucate
    trucate table "SITE_BONUS" /It should be : tuncate
    truncate table SITE_BONUSHope this helps,
    Sam
    +Please reward good answers by marking them correct or helpful!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can I give access to truncate one table only ?

    Hi,
    We have system where it is deleting one table and inserting records using pro-cobol in a table owned by another schema. It means user b is inserting records in a's table i.e. t. Can I give access to truncate only a.t ? delete any table or drop any table will give access to b to truncate any table in 'a'. I do not want this. How can I achive this ?
    thanks & regards
    PJP

    As Justin already said there is no separate right to simple GRANT TRUNCATE ON TABLE to user.
    From the docs: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10006.htm#sthref9966
    To truncate a table or cluster, the table or cluster must be in your schema or you must have DROP ANY TABLE system privilege.
    So the best way would be to encapsulate this login in a packaged procedure as described by Justin.

  • Help with truncating a table using plsql procedure in different schema

    I have a plsql procedure in schema A that truncates a table that is given in as parameter.
    create or replace procedure truncate_table(schema, table_name)
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||schema||'.'||table_name;
    end;
    The above procedure has public execute grant.
    I need to truncate a table in schema B. I have a plsql procedure in schema B that calls the truncate_table procedure and passes in the schema B table name.
    Since the table is in schema B, should the delete grant on the table be given to user A or user B to truncate the table in schema B?
    Thanks in advance.

    Procedure created in schema A
    create or replace
    procedure truncate_table(l_schema varchar2, table_name varchar2) authid current_user
    as
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||l_schema||'.'||table_name;
    end;from schema B
    grant delete on table1 to Schema_A
    from schema A
    exec truncate_table('Schema_B','Table1');
    Hope this helps.
    Alvinder

  • How to TRUNCATE a table dynamically in a Stored Procedure?

    Hi everyone, How can I create a Procedure with dynamic sql to truncate a table name I pass by every time in Oracle? I am running the following query and nothing happens. It neither creates the procedure nor errors out.
    CREATE OR REPLACE PROCEDURE TruncateTable(TableName IN VARCHAR2(50))
    IS
    BEGIN
    SQLCmd VARCHAR(200);
    BEGIN
    SQLCmd := 'TRUNCATE TABLE ' || TableName;
    EXECUTE IMMEDIATE SQLCmd;
    END;
    Could someone please help me?
    Thanks

    Thanks Brendan for the reply. But, it neither does anything after I add a "/" on line9. Just wondering if the syntax of the proc is correct?

  • Privilege for truncating a table of other schema

    Hi friends
    I need to truncate a table of other schema. What privilege the other user has to give to carry out it.
    Thanks
    Edited by: user12892846 on 01-abr-2010 15:59

    DROP ANY TABLEWhile technically correct, above is somewhat dangerous because every schema could be impacted; even SYS.
    Assume SCHEMA_A owns TABLE_A & procedure below.
    CREATE & REPLACE PROCEDURE TRUNCATE_TABLE_A
    AS
    BEGIN
    EXECUTE IMMEDIATE 'TRUNCATE TABLE TABLE_A';
    END TRUNCATE_TABLE_A;
    GRANT EXECUTE ON TRUNCATE_TABLE_A TO SCHEMA_B;
    By doing as above SCHEMA_A can control who & which table(s) can be impacted (in is own schema only).
    Edited by: sb92075 on Apr 1, 2010 7:06 PM

  • Problem in enabling constraint - after disabling and truncation of table .

    Hello Friends,
    I have a table called DRR_TABLES that has list of table names . The requirement is to truncate the tables present in DRR_TABLES except KEY_IDS table and table_name like '%TYPE%' table.
    written a procedure . successfullly truncating the tables from DRR_TABLES but while enabling constraints after truncation , I am getting problem in enabling constraints .
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    ORA-06512: at "schema123.TRUNCATE_DRR_TABLES ", line 49
    ORA-06512: at line 1
    Heres is the code .
    PROCEDURE TRUNCATE_DRR_TABLES is
    x varchar2(200);
    v_tablecount number := 0;
    cursor c is select TABLE_NAME from DRR_TABLES where population_source='PUBLISHING' and TABLE_NAME != 'KEY_IDS' and TABLE_NAME NOT LIKE '%TYPE%';
    BEGIN
    DBMS_OUTPUT.PUT_LINE (' TRUNCATING DRR TABLES ...........');
    OPEN c ;
    LOOP
    FETCH c INTO x ;
    EXIT WHEN c%NOTFOUND;
    for c1 in (select table_name, constraint_name from user_constraints where TABLE_NAME = x and status ='ENABLED' ORDER BY CONSTRAINT_TYPE DESC )
    loop
    begin
    execute immediate ('alter table '||c1.table_name||' disable constraint '||c1.constraint_name|| ' cascade');
    NULL;
    end;
    end loop;
    EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || x ;
    v_tablecount := v_tablecount + 1 ;
    DBMS_OUTPUT.PUT_LINE('TABLE TRUNCATED :'|| x );
    END LOOP ;
    DBMS_OUTPUT.PUT_LINE (' TOTAL TABLES TRUNCATED ' || v_tablecount );
    CLOSE c;
    OPEN c ;
    LOOP
    FETCH c INTO x ;
    EXIT WHEN c%NOTFOUND;
    for c2 in (select table_name, constraint_name from user_constraints where TABLE_NAME = x and status = 'DISABLED' ORDER BY CONSTRAINT_TYPE)
    loop
    begin
    execute immediate ('alter table '||c2.table_name||' enable constraint '||c2.constraint_name);
    NULL;
    end;
    end loop;
    END LOOP ;
    CLOSE c ;
    END TRUNCATE_DRR_TABLES ;
    LINE 49 is the line corresponding to enable constraint statement.
    Edited by: kumar73 on 3 Sep, 2012 11:44 PM

    It is such a pity that a user having 321 posts till date is unaware of basics of Posting a Question.
    1. You need to provide us with your Oracle version
    select * from v$version;2. You need to understand and get accustomed to using tags before and after Code or SQL's for better readability.
    3. You need to provide us with the Table Structure and the Constraints Definition.
    There are many things that looks like Bad Coding practices:
    <font face="Times New Roman" size=2>
    1. Avoid RBAR (Loops).
    2. Implement Bulk Collect.
    3. Why do you need to disable the constraints before truncating? Are you kind of handling the Referential Integrity Constraints?
    4. Duplicate checking of Disabled Constraints.
    5. When the procedure is being executed at Production Environment, are you going to Monitor the DBMS_OUTPUT? Why not Log the Statements into a LOG Table?
    6. Why use a TableCount variable? Would the TableCount Variable be not equal to the Number of Records returned by Cursor C?
    7. What is the need to use a NULL statement after every Execute Immediate?
    8. What is the Need to surround each execute Immediate with Begin .. End block?
    9. Where is your Exception handling Block? Forgot to write?
    </font>
    What has been your effort in finding which Constraint/Table is causing you the trouble?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • RSECLOG - how do i delete/truncate this table???

    Hello BW people,
    we turned on auth analysis 6 or 7 months ago and now we have a 260 gb table and i am trying to delete the logs manually thru RSECPROT but it is taking forever to delete one log (approx 30 mins).
    is there either a program in sap or a manual way of deleteing or truncating this table?
    any help would be very much appreciated.

    Thanks Jorge,
    this has worked perfectly.
    I thought there might be a sap program to do this, but this worked.
    thx,
    Erik

  • How to truncate fact tables using wb_truncate_table

    Hi,
    I've got a sequence of mappings that load various staging tables, dimensions and fact tables.
    At present, I truncate the fact tables manually before loading the dimensions (to avoid foreigh key errors), but would like to write mappings to do the truncations.
    I tried creating mappings using wb_truncate_table in a Pre-Mapping Process operator (using a constant for the filename), but can't figure out how to get this to actually truncate the fact table.
    The manual says to "connect the output attribute of the Pre-Mapping Process operator to the input group of a target operator." However the PMP operator in my mapping doesn't have an output operator (and the add button is greyed out).
    Sorry if I'm missing something obvious, but can anybody help, or advise on a better way to truncate my fact tables before reloading the dimensions?
    Thanks in advance.
    Chris

    got that to work using WB_TRUNCATE_TABLE in a PMP in the first mapping to >populate one of the fact table's dimensions. The problem I was having was in >trying to create a mapping just to do the truncate, but I see now that's not the >way to go.If you want to create a mapping that just truncate some table(s) - it's very easy.
    1. Just create your own function that returns, let's say, char. Inside this function, call WB_TRUNCATE_TABLE and return dummy char (e.g. '1'). Then create some dummy table with only one colum of char type.
    2. Create mapping. place constant operator, your function as transformation operator, and dummy table. Link them CONSTANT - TRANSFORMATION - TABLE.
    That's all. If you want to truncate more tables within one mapping, just add more FUNCTIONS and add more attributes (table names) to the constant operator.

  • Saving texts in transparent table

    HI all,
               How can we create a transparent table and save texts in it.
            Actually my requirement is to create a button on an ALV and when user clicks that button then a text editor should open and whatever user enter in that window should get saved in a transparent table.
    Does anyone have any idea how to do this??
    please help me as soon as possible.
    regards,
    kushagra

    Hi,
    After setting all field catelogs and all
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program       = ws_repid  ---report name
                i_callback_pf_status_set = 'GUI_STAT'
                i_callback_user_command  = 'STAT'
                is_layout                = gs_layout
                it_fieldcat              = i_fieldcat[]
           TABLES
                t_outtab                 = i_zaw_pol_plan.
      IF sy-subrc <> 0.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " change_data
    **--Setting Status of outout screen
    FORM gui_stat USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
      SET TITLEBAR text-005.
    ENDFORM.
    **--Calling the subroutine when button clicked on output
    FORM stat USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
      DATA selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN 'SAVE'.      
        LOOP AT i_zaw_pol_plan WHERE flag EQ c_x.
             here you will get the selected data and update the table with this
       ENDLOOP.
      ENDCASE.
    ENDFORM.
    double click on PF-STATUS 'STANDARD' in above code in application tool bar add button fcode and text and icon.

  • How to truncate  schema1 table from schema 2 -URGENT

    Hi all
    Please tell me is there any grant like that
    regards

    IS this
    grant drop any table to schema 2
    only way PapinRTFM: http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_107a.htm
    Prerequisites
    To truncate a table or cluster, the table or cluster must be in your schema or you must have DROP ANY TABLE system privilege. :)

Maybe you are looking for

  • How can I associate an ActionListener with a specific button

    I modified the code a lot. Everything works except that it does not associate the actionListener with the button. It will do the action when the window is minimized or maximized, but not when the button is clicked. //July 2, 2011 //Multiplication Tab

  • P67 Lack of Support?

    I have both: p67a-gd65 z68-gd65 The Z68 has both Click Bios 2 and an Ivy Bridge UEFI update Even the H61 boards are getting an Ivy Bridge update Are MSI going to update the P67 at some point? 

  • Delivery quantity greater than confirmed quantity in sales order

    Hi experts, Quantity in delivery order can be changed to more than the confirmed quantity in sales order when there is sufficient stock. (Setting "Check overdelivery" in 0VLP already maintained "B-Situation rejected with an error message"). Anyway in

  • Installation Error Exit Code 20

    I am attempting to install InDesign CS 5.5 on a new Windows 7 computer.  I received an installation error Exit Code 20.  Adobe Chat told me I had to open a discussion in the forum to resolve this issue.  Is anyone able to help me fix this issue? 

  • I cant log into my macbook pro

    and it doesnt recognize my apple ID password even after i reset it. helppp