Free space in specific table

Hi all,
i am oracle dba, so can anyone tell me that any command or query to know the free and used space in a paticular table.quick response will higly appreciate.
Regards

Tom Kyte has authored a SHOW_SPACE procedure that gives all necessary insight.
http://www.oracle-base.com/dba/monitoring/show_space.sql

Similar Messages

  • How to calculate the percentage of free space for a table in Oracle

    okay, I am a little confused here. I have been searching the web and looking at a lot of documents. What I basically want to find out is this, how do I calculate the difference between the number of bytes a table is using and the total bytes allocated to a table space (going that way to get percent free for a particular table). So I need a byte count of a table and total table space and the percentage difference. I have been looking at the DBA_TABLES DBA_TABLESPACES and DBA_SEGMENTS views. I have tried to calculated the space as num_rows * avg_row_len (if I am wrong, let me know). I have been trying to compare that calculation to the number in DBA_TABLESPACES and DBA_SEGMENTS. I am just looking for the total space allocated to the table space that the table sits in (seem logical right now) to make the percentage value work. Thus I want to be able to track the table as it grows as compated to the table space it sits in to see a value as it changes over time (days, weeks, etc.) each time I run this script I am working on.
    Can someone get me straight and help me to find out if I am looking in the right places. Any advice would help.
    Edward

    You can use a little modified version of dbms_space from Tom, show_space. Have a look,
    SQL> create table test222 as select * from all_objects;
    Table created.
    SQL> delete from test22 where rownum<=100;
    delete from test22 where rownum<=100
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> delete from test222 where rownum<=100;
    100 rows deleted.
    SQL> analyze table test222 compute statistics;
    Table analyzed.
    SQL>  create or replace procedure show_space
      2  ( p_segname in varchar2,
      3    p_owner   in varchar2 default user,
      4    p_type    in varchar2 default 'TABLE',
      5    p_partition in varchar2 default NULL )
      6  -- this procedure uses authid current user so it can query DBA_*
      7  -- views using privileges from a ROLE and so it can be installed
      8  -- once per database, instead of once per user that wanted to use it
      9  authid current_user
    10  as
    11      l_free_blks                 number;
    12      l_total_blocks              number;
    13      l_total_bytes               number;
    14      l_unused_blocks             number;
    15      l_unused_bytes              number;
    16      l_LastUsedExtFileId         number;
    17      l_LastUsedExtBlockId        number;
    18      l_LAST_USED_BLOCK           number;
    19      l_segment_space_mgmt        varchar2(255);
    20      l_unformatted_blocks number;
    21      l_unformatted_bytes number;
    22      l_fs1_blocks number; l_fs1_bytes number;
    23      l_fs2_blocks number; l_fs2_bytes number;
    24      l_fs3_blocks number; l_fs3_bytes number;
    25      l_fs4_blocks number; l_fs4_bytes number;
    26      l_full_blocks number; l_full_bytes number;
    27
    28      -- inline procedure to print out numbers nicely formatted
    29      -- with a simple label
    30      procedure p( p_label in varchar2, p_num in number )
    31      is
    32      begin
    33          dbms_output.put_line( rpad(p_label,40,'.') ||
    34                                to_char(p_num,'999,999,999,999') );
    35      end;
    36  begin
    37     -- this query is executed dynamically in order to allow this procedure
    38     -- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
    39     -- via a role as is customary.
    40     -- NOTE: at runtime, the invoker MUST have access to these two
    41     -- views!
    42     -- this query determines if the object is a ASSM object or not
    43     begin
    44        execute immediate
    45            'select ts.segment_space_management
    46               from dba_segments seg, dba_tablespaces ts
    47              where seg.segment_name      = :p_segname
    48                and (:p_partition is null or
    49                    seg.partition_name = :p_partition)
    50                and seg.owner = :p_owner
    51                and seg.tablespace_name = ts.tablespace_name'
    52               into l_segment_space_mgmt
    53              using p_segname, p_partition, p_partition, p_owner;
    54     exception
    55         when too_many_rows then
    56            dbms_output.put_line
    57            ( 'This must be a partitioned table, use p_partition => ');
    58            return;
    59     end;
    60
    61
    62     -- if the object is in an ASSM tablespace, we must use this API
    63     -- call to get space information, else we use the FREE_BLOCKS
    64     -- API for the user managed segments
    65     if l_segment_space_mgmt = 'AUTO'
    66     then
    67       dbms_space.space_usage
    68       ( p_owner, p_segname, p_type, l_unformatted_blocks,
    69         l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
    70         l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
    71         l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
    72
    73       p( 'Unformatted Blocks ', l_unformatted_blocks );
    74       p( 'FS1 Blocks (0-25)  ', l_fs1_blocks );
    75       p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
    76       p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
    77       p( 'FS4 Blocks (75-100)', l_fs4_blocks );
    78       p( 'Full Blocks        ', l_full_blocks );
    79    else
    80       dbms_space.free_blocks(
    81         segment_owner     => p_owner,
    82         segment_name      => p_segname,
    83         segment_type      => p_type,
    84         freelist_group_id => 0,
    85         free_blks         => l_free_blks);
    86
    87       p( 'Free Blocks', l_free_blks );
    88    end if;
    89
    90    -- and then the unused space API call to get the rest of the
    91    -- information
    92    dbms_space.unused_space
    93    ( segment_owner     => p_owner,
    94      segment_name      => p_segname,
    95      segment_type      => p_type,
    96      partition_name    => p_partition,
    97      total_blocks      => l_total_blocks,
    98      total_bytes       => l_total_bytes,
    99      unused_blocks     => l_unused_blocks,
    100      unused_bytes      => l_unused_bytes,
    101      LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
    102      LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
    103      LAST_USED_BLOCK => l_LAST_USED_BLOCK );
    104
    105      p( 'Total Blocks', l_total_blocks );
    106      p( 'Total Bytes', l_total_bytes );
    107      p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
    108      p( 'Unused Blocks', l_unused_blocks );
    109      p( 'Unused Bytes', l_unused_bytes );
    110      p( 'Last Used Ext FileId', l_LastUsedExtFileId );
    111      p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
    112      p( 'Last Used Block', l_LAST_USED_BLOCK );
    113  end;
    114
    115  /
    Procedure created.
    SQL> desc show_space
    PROCEDURE show_space
    Argument Name                  Type                    In/Out Default?
    P_SEGNAME                      VARCHAR2                IN
    P_OWNER                        VARCHAR2                IN     DEFAULT
    P_TYPE                         VARCHAR2                IN     DEFAULT
    P_PARTITION                    VARCHAR2                IN     DEFAULT
    SQL> set serveroutput on
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SCOTT.SHOW_SPACE", line 44
    ORA-06512: at line 1
    SQL> conn / as sysdba
    Connected.
    SQL> grant sysdba to scott;
    Grant succeeded.
    SQL> conn scott/tiger as sysdba
    Connected.
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'SHOW_SPACE' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    SQL> exec scott.show_space('TEST222','SCOTT');
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> exec scott.show_space('TEST222','SCOTT');
    Unformatted Blocks .....................               0
    FS1 Blocks (0-25)  .....................               0
    FS2 Blocks (25-50) .....................               1
    FS3 Blocks (50-75) .....................               0
    FS4 Blocks (75-100).....................               1
    Full Blocks        .....................             807
    Total Blocks............................             896
    Total Bytes.............................       7,340,032
    Total MBytes............................               7
    Unused Blocks...........................              65
    Unused Bytes............................         532,480
    Last Used Ext FileId....................               4
    Last Used Ext BlockId...................           1,289
    Last Used Block.........................              63
    PL/SQL procedure successfully completed.
    SQL>http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5350053031470
    I use this to find the space allocations.
    Just read your post again,this is not going to show you the percentage of the free/used space. This is going to be the number of blocks which are free/used. For the growth trend, you can look at (in 10g) Oracle EM. It has added now,Segment Growth Trend report which can show you for each object,comparing to the allocated space to the object,how much space is being used by it.
    HTH
    Aman....

  • Detemining the free space for each tables before Archiving an object.

    Hi Everyone,
    I want to know,how can i get the information about the how much space will get free from each table which is related to an archiving object <b>before</b> i perform
    archiving on that particular object.
    Are there any transactions for the same, or some transaction which can be related to these.
    eg:FI_DOCUMNT is related to lots of table, before i archive this object, i want to know that space that will be free from all the tables individually which are affected by this object.
    Regards,
    Nipun Sharma

    Hi Nipun,
    as far as I know: there is no easy tool to get this numbers. But on the other hand, you don't need exact numbers, estimations will do.
    It's a good idea to start with the biggest objects: take DB02, make a detailed analysis where you select the biggest tables -> corresponding archive objects should be your main focus (for the beginning).
    Count for the biggest tables in each objects the entries per year (or month, whatever periods you are interested in). Most tables have creation date to do so, otherwise go for number range. For some numbers you could search the creation date, the rest is estimation again.
    Then you will have an idea, which volume was created in which time frame.
    Still you need some test archive runs (in PRD or an (old) copy, at least for an example amount of data): you need to know, which % of the documents can technically be archived, how much will stay open because of missing closing. That's critical information (maybe 90% will stay in system) and can only be analyzed by SARA test runs - if you identify the missing object status, you can go on selecting this directly, but in the beginning you need the archive run.
    With the volume / time frame and the percentage, which can be deleted you should be able to give estimations based on current total object size. Make clear, that you talk about estimations: every single object will be checked for having correct status - before this isn't done (in a test run), no one can tell exact numbers.
    Hope, this will help you,
    regards,
    Christian

  • Fill free space with specific playlist

    Hi Guys,
    Had a search but couldn't see the answer.
    How do I fill the free space on my iPhone with songs from a specific playlist on iTunes then force iTunes to re-randomize on each sync?
    Thanks!
    Max

    Bump?

  • Free space showing in Table space but not updated on os file system.

    Hi Support,
    I am using oracle 10.2.0.4.0 in ECC6.0. OS is Solaris 10 (Linux).
    We deleted all xml messages from my PI/XI server. its successfully deleted even table space showing free space almost 400GB in DB02 and from brtools also. But from OS side OS file system not showing free space,
    Is any body know about this issue????  do i need to reboot system or any other solution.
    Thanks,
    Kazi Faizan.

    Try to set it up as new device and restore again from the backup:
    How to erase your iOS device and then set it up as a new device or restore it from backups

  • How Find space Used by Tables and Indexes

    Dear All(s)
    How i check space used (and number of rows) by each table and index in schema. ( can i check current space utilization and sysdate-date past in time)
    How i can check used, and free space for each database and tablespace.
    Thanks

    You can always use the search feature
    anyway
    how to calculate the percentage of free space for a table in Oracle
    Re: incorrect free space in dba_free_space
    These links could give you all the necessary info

  • Defining free space in segments

    hello
    how i can define amount of free space in segments(tables,indexes,..) by query of dictionary views?
    please write an example
    thanks

    no user_segments and user_extents views don't represent free space
    they give me total segment space
    Message was edited by:
    khosravi

  • Table Partitions and Rolling Window: free space not reclaimed

    I have a couple of processes that involve the rolling window scenario where we drop an old partition and add a new partition monthly. We are seeing, however, that free space is not being reclaimed, and so I keep having to feed new datafiles into the tablespace (which is LMT). I was (mistakenly, it seems) under the impression that dropping a partition frees up that space for re-use.
    We're currently on Oracle 10gR2 (10.2.0.2), but these tablespaces were orginally created in 9i. I've read that one solution is to implement "table shrinking," however I also see that is only available on tables in an ASSM tablespace. I see that ASSM is the default for tablespaces in 10gR2, but since my tablespaces were created in 9i, I assume they are not ASSM.
    I'd like to see what other people think of this scenario. Surely a lot of people do the rolling window scenario and need space reclaimed.

    No, it is of concern because Sanadra was messing with the partitions. She could have inadvertantly caused something to happen, in this case the free-space issue, and it's imperative to get all of the details.
    My iMac 27' Late-2012 does not have a fusion drive, yet shows that the type is "internal" the original poster doesn't indicate that.

  • Table free space

    Is there any way to find the amount of free space that will be created when we delete data from any table.
    Suppose we delete 10,000 rows from a table, how much free space will be created ?

    I wish to mention as below : (Oracle 10.2.0.1 on windows XP Prof Service Pack 2)
    select ts.tablespace_name, to_char(sum(nvl(fs.bytes,0)), '999999999999999') as MB_FREE
      from dba_free_space fs, dba_tablespaces ts
      where fs.tablespace_name(+) = ts.tablespace_name
      group by ts.tablespace_name;
    TABLESPACE_NAME                MB_FREE
    USERS                                 280231936
    Then I created one table in scott schema (which is having privilege on users tbs)
    create table t(name varchar2(20),age number(3));
    Now check space again :
    SYS@orcl> /
    TABLESPACE_NAME                MB_FREE
    USERS                                 280166400
    Means 280231936-280166400=65536 bytes consumed above create table command.  Why?
    SCOTT@orcl> select bytes,blocks,extents from user_segments where segment_name='T';
                  BYTES              BLOCKS             EXTENTS
               65536.00                8.00                1.00
    But why it taken 65536 bytes?
    Yes it will take 65536 bytes because my db_block_size=8192 bytes and by default it will create 1 extent of 8 blocks.  It has not occupied all 65536 bytes, but has been allocated for the table; means if insert 65536 bytes data there will be only 1 extent (if we don’t say alter table t allocate extent)  Now suppose if I said alter table t allocate extent; then :
    SCOTT@orcl> select bytes,blocks,extents from user_segments where segment_name='T';
                  BYTES              BLOCKS             EXTENTS
              131072.00               16.00                2.00
    So, at this moment table size is 131072 and if again check the size of users tablespace then it :
    SYS@orcl> /
    TABLESPACE_NAME                MB_FREE
    USERS                                 280100864 (280166400 – 65536)
    Now, table T has been allocated space for 131072 bytes, but how much actual data it is carrying (data size of table) :
    So, I will : (simple method by avg_row_len column, after analyze table)
    select table_name,num_rows,avg_row_len, (num_rows*avg_row_len) "Data in Table" from user_tables where table_name='T';
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       0           0             0
    Now I will insert a row in the table :
    insert into t values('Girish',40);
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       0           0             0
    analyze table t compute statistics;
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       1          13            13
    insert into t values('Alok',42);
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       1          13            13
    analyze table t compute statistics;
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       2          12            24
    Commit;
    Ok.  At this moment it is having 24 bytes data.  Now I am going to delete 1 row :
    delete from t where name='Girish';
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       2          12            24
    TABLE_NAME                       NUM_ROWS AVG_ROW_LEN Data in Table
    T                                       1          11            11
    Now I wish to gain 24-11=13 bytes to tablespace.
    SCOTT@orcl> select bytes,blocks,extents from user_segments where segment_name='T';
         BYTES     BLOCKS    EXTENTS
        131072         16          2
    Alter table t move;
    SCOTT@orcl> select bytes,blocks,extents from user_segments where segment_name='T';
         BYTES     BLOCKS    EXTENTS
         65536          8          1
    Means, it deallocated / released all extent/space and reached upto last shrinkable space.  Since I don’t have any associated index with this table; otherwise I will have to rebuild them.HTH
    Girish Sharma

  • Specific free Space in Flash on 6509

    is there any specific free space should be left in the Flash on 6509?
    because 6509 has got 128DRAM 32MB Flash.
    assume that only 2MB of free space is avaliable in flash, will that affect anything? according to me, i was assumed that only in DRAM free space is necessary. am i right? if so please correct me

    use the following CONFIG REGISTER CALCULATOR to determine what your 0x2 confReg will do when the router boots:
    should probably be 0x2102 or the likes..verify with the tool.
    see this link for the Configuration Register Calculator:
    http://gtcc-it.net/billings/configreg.htm

  • How to find block free space  and PCTUSED FOR THE TABLE

    HI all,
    Due to performance issues for my database , my management ask me to reset the PCTUSED and PCTFREE values , and my doubt is
    1)How to find the current PCTUSED and PCTFREE values.
    2)How to find block free space and PCTUSED FOR THE TABLE.
    Please help me out regarding this.
    Regards,
    Vamsi.

    1)version is 10.2.0.4
    2)output of query
    tablespace extent_management allocation_type segment_space_management
    SYSTEM     LOCAL     SYSTEM     MANUAL
    UNDOTBS1     LOCAL     SYSTEM     MANUAL
    SYSAUX     LOCAL     SYSTEM     AUTO
    TEMP     LOCAL     UNIFORM     MANUAL
    USERS     LOCAL     SYSTEM     AUTO
    UNDOTBS2     LOCAL     SYSTEM     MANUAL
    INS     LOCAL     SYSTEM     AUTO
    CONFTBS     LOCAL     SYSTEM     AUTO
    REINS     LOCAL     SYSTEM     AUTO
    ANALYST     LOCAL     SYSTEM     AUTO
    BI     LOCAL     SYSTEM     AUTO
    INTRFC     LOCAL     SYSTEM     AUTO
    COGNOS     LOCAL     SYSTEM     AUTO
    TS_INDX     LOCAL     SYSTEM     AUTO
    TS_CHOLAWEB     LOCAL     SYSTEM     AUTO
    TS_DASBOARD     LOCAL     SYSTEM     AUTO

  • Free space/table space

    Hi all,
    I have deleted some millions of records from a table and comitted it. but did not see the expected space savings (expected over 10GM)
    Kindly advice me on this.
    Regards,
    Jaggyam

    You did save space in the table. If you now insert a load of rows into it, they will go in the space you freed up by the delete (assuming conventional path rather than direct path insert).
    MOVE as mentioned above would go like:
    ALTER TABLE yourtable MOVE;then rebuild the indexes.
    (See ALTER TABLE, MOVE clause for full syntax.)

  • Free space on boot drive constantly decreases until reboot

    Hi there. I have a really weird thing happening that I've never seen before.
    I'm running 10.7.4 on an iMac, and have about 45GB free on the system drive. At least that's right after I boot up the system. After that, the free space available on my HD slowly but constantly decreases, and the computer slowly but surely becomes less responsive. When the free space on the boot drive gets down around 37GB (which takes 2-3 days... I usually never turn the machine off) I get so many spinning beach balls... in ALL applications... that the computer becomes basically unuseable and I am forced to reboot. But as soon as I do, free space is back up to 45GB, and computer is snappy and fast again.
    What the heck?

    Your problem is excessive swapping of data between physical memory and virtual memory.
    That can happen for two reasons:
    (1) You have a long-running process with a memory leak (i.e., a bug), or
    (2) You don't have enough memory installed for your usage pattern.
    Tracking down a memory leak can be difficult, and it may come down to a process of elimination. In Activity Monitor, select All Processes from the menu in the toolbar, if not already selected. Click the heading of the Real Mem column in the process table once or twice to sort the table with the highest value at the top. If one process (not including "kernel_task") is using much more memory than all the others, that could be an indication of a leak. A better indication would be a process that continually grabs more and more memory over time without ever releasing it.
    This suggestion is only for users familiar with the shell. For a more precise, but potentially misleading, test, run the following command:
    sudo leaks -nocontext -nostacks process | grep total
    where process is the name of a process you suspect of leaking memory. Almost every process will leak some memory; the question is how much, and especially how much the leak increases with time. I can’t be more specific. See the leaks(1) man page and the Apple developer documentation for details:
    Memory Usage Performance Guidelines: About the Virtual Memory System
    If you don't have an obvious memory leak, your options are to install more memory (if possible) or to run fewer programs simultaneously.

  • Can I run a Unix shell when insert some record on a specific table?

    Can I run a Unix shell when insert some record on a specific table?
    I need to run a Unix shell when a record be insert on a table. Is there a way in order to do that?
    THanks,
    Carlos.

    1. Make a backup of the extproc.c file in the c:\orant\rdbms80\extproc
    directory.
    2. Create a file called extern.c in the c:\orant\rdbms80\extproc directory.
    The "extern.c" file :
    #include <oci.h>
    #define NullValue -1
    #include<stdio.h>
    #include<string.h>
    long __declspec(dllexport) OutputString(context ,
                             path , path_ind ,
                             message , message_ind,
                             filemode , filemode_ind ,
                             len , len_ind )
    char *path;
    char *message; 
    char *filemode;
    int len;
    OCIExtProcContext *context;
    short path_ind;
    short message_ind;
    short filemode_ind;
    short len_ind;
    FILE *file_handle;
    int i ;
    char str[3];
    int value;
    /* Check whether any parameter passing is null */
    if (path_ind == OCI_IND_NULL || message_ind == OCI_IND_NULL ||
    filemode_ind == OCI_IND_NULL || len_ind == OCI_IND_NULL ) {
    text initial_msg = (text )"One of the Parameters Has a Null Value!!! ";
    text *error_msg;
    /* Allocate space for the error message text, and set it up.
    We do not have to free this memory - PL/SQL will do that automatically. */
    error_msg = OCIExtProcAllocCallMemory(context,
    strlen(path) + strlen(initial_msg) + 1);
    strcpy((char *)error_msg, (char *)initial_msg);
    /*strcat((char *)error_msg, path); */
    OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
    /* OCIExtProcRaiseExcp(context, 6502); */
    return 0;
    /* Open the file for writing. */
    file_handle = fopen(path, filemode);
    /* Check for success. If not, raise an error. */
    if (!file_handle) {
    text initial_msg = (text )"Cannot Create file ";
    text *error_msg ;
    /* Allocate space for the error message text, and set it up.
    We do not have to free this memory - PL/SQL will do that automatically. */
    error_msg = OCIExtProcAllocCallMemory(context,
    strlen(path) + strlen(initial_msg) + 1);
    strcpy((char *)error_msg, (char *)initial_msg);
    strcat((char *)error_msg, path);
    OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
    return 0;
    i = 0;
    while (i < len)
    /* Read the hexadecimal value(1). */
    str[0] = message;
         i++;
    /* Read the hexadecimal value(2). */
    str[1] = message[i];
    /* Convert the first byte to the binary value. */
    if (str[0] > 64 && str[0] < 71)
    str[0] = str[0] - 55;
    else
    str[0] = str[0] - 48;
    /* Convert the second byte to the binary value. */
    if (str[1] > 64 && str[1] < 71)
    str[1] = str[1] - 55;
    else
    str[1] = str[1] - 48;
    /* Convert the hex value to binary (first & second byte). */
    value = str[0] * 16 + str[1];
    /* Write the binary data to the binary file. */
    fprintf(file_handle,"%c",value);
              i++;
    /* Output the string followed by a newline. */
    /* fwrite(message,len,1,file_handle); */
    /* Close the file. */
    fclose(file_handle);
    3. Use the make.bat available in the c:\orant\rdbms80\extproc directory. You
    need to run vcvars32.bat file before running this batch file. This will
    create a dll file.
    4. Configure the tnsnames.ora and the listener.ora files.
    The tnsnames.ora should contain the following entries.
    extproc_connection_data.world =
    (DESCRIPTION =
    (ADDRESS =
    (PROTOCOL = IPC)
    (KEY = ORCL)
    (CONNECT_DATA = (SID = extproc)
    The listener.ora should contain the following entries.
    # P:\ORANT\NET80\ADMIN\LISTENER.ORA Configuration File:p:\orant\net80\admin\listener.ora
    # Generated by Oracle Net8 Assistant
    LISTENER8 =
    (ADDRESS = (PROTOCOL = TCP)(HOST = winnt_nsc)(PORT = 1521))
    SID_LIST_LISTENER8=
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = winnt_nsc)
    (SID_NAME = ORCL)
    (SID_DESC =
    (SID_NAME = extproc)
    (PROGRAM = extproc)
    5. Login from sqlplus and issue the following statements.
    create library externProcedures as 'C:\orant\RDBMS80\EXTPROC\extern.dll';
    Create or replace PROCEDURE OutputString(
    p_Path IN VARCHAR2,
    p_Message IN VARCHAR2,
    p_mode in VARCHAR2,
    p_NumLines IN BINARY_INTEGER) AS EXTERNAL
    LIBRARY externProcedures
    NAME "OutputString"
    With context
    PARAMETERS (CONTEXT,
    p_Path STRING,
    p_path INDICATOR,
    p_Message STRING,
    p_message INDICATOR,
    p_mode STRING,
    p_mode INDICATOR,
    p_NumLines INT,
    p_numlines INDICATOR);
    This is the pl/sql block used to write the contents of the BLOB into a file.
    Set serveroutput on before running it.
    SQL> desc lob_tab;
    Name Null? Type
    C1 NUMBER
    C2 BLOB
    lob_tab is the table which contains the blob data.
    declare
    i1 blob;
    len number;
    my_vr raw(10000);
    i2 number;
    i3 number := 10000;
    begin
    -- get the blob locator
    SELECT c2 INTO i1 FROM lob_tab WHERE c1 = 2;
    -- find the length of the blob column
    len := DBMS_LOB.GETLENGTH(i1);
    dbms_output.put_line('Length of the Column : ' || to_char(len));
    -- Read 10000 bytes at a time
    i2 := 1;
    if len < 10000 then
    -- If the col length is < 10000
    DBMS_LOB.READ(i1,len,i2,my_vr);
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*len);
    -- You have to convert the data to rawtohex format. Directly sending the buffer
    -- data will not work
    -- That is the reason why we are sending the length as the double the size of the data read
    dbms_output.put_line('Read ' || to_char(len) || 'Bytes');
    else
    -- If the col length is > 10000
    DBMS_LOB.READ(i1,i3,i2,my_vr);
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*i3);
    dbms_output.put_line('Read ' || to_char(i3) || ' Bytes ');
    end if;
    i2 := i2 + 10000;
    while (i2 < len ) loop
    -- loop till entire data is fetched
    DBMS_LOB.READ(i1,i3,i2,my_vr);
    dbms_output.put_line('Read ' || to_char(i3+i2-1) || ' Bytes ');
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'ab',2*i3);
    i2 := i2 + 10000 ;
    end loop;
    end;

  • Taking free space out after TDMS copy

    Hello Experts,
    I have performed a TDMS copy from Production to one of our quality systems. Since I have taken only 6 months data the size of our quality system Database is reduced which was previously equal to Production.
    1)At present around 1 TB of space is free in PSAPSR3 tablespace whichI want to bring to OS level filesystem. I do not wantto go for whole tablespace reorg due to some specific reasons like large no of tables with Long fields, space issues etc.
      If anyone of you have faced a similarsituation pleasedo guide.
    Regards,
    Umesh

    Hello Rajesh,
    I already found tables for reorg and tried reorg for some of those tables , but the space released after table reorg is at tablespace level and not at OS file system.  So again the issue remains the same to pull out space from tablespace without reorg.
    I have searched various forums but everthing at the end comes to tablespace reorg . Since I have space contraints , I am searching for workaround for this.
    Regards,
    Umesh.

Maybe you are looking for