Single table hash clusters

I created a single table hash cluster like this :
create tablespace mssm datafile 'c:\app\mssm01.dbf' size 100m
segment space management manual;
create cluster hash_cluster_4k
( id number(2) )
size 8192 single table hash is id hashkeys 4 tablespace mssm;
-- Created a table in cluster with row size such that only one record fits one block and inserted 5 records each with a distinct key value
CREATE TABLE hash_cluster_tab_8k
( id number(2) ,
txt1 char(2000),
txt2 char(2000),
txt3 char(2000)
CLUSTER hash_cluster_8k( id );
Begin
for i in 1..5 loop
insert into hash_cluster_tab_8k values (i, 'x', 'x', 'x');
end loop;
end;
exec dbms_stats.gather_table_stats(USER, 'HASH_CLUSTER_TAB_8K', CASCADE=>true);
Now, If I try to access record with id = 1 - It shows 2 I/O's (cr = 2) instead of single I/O as is expected in a hash cluster.
Rows Row Source Operation
1 TABLE ACCESS HASH HASH_CLUSTER_TAB_8K (cr=2 pr=0 pw=0 time=0 us)
If I issue the same query after creating unique index on hash_cluster_tab(id), the execution plan shows hash access and single I/O (cr = 1).
Does it mean that to have single I/o in a single table hash cluster, we have to create unique index? Won't it create additional overhead of maintaining an index?
What is the second I/O needed for in case unique index is absent?
I would be extremely thankful if gurus could explain this behaviour .
Thanks in advance ..

>
Now, If I try to access record with id = 1 - It shows 2 I/O's (cr = 2) instead of single I/O as is expected in a hash cluster.
1 TABLE ACCESS HASH HASH_CLUSTER_TAB_8K (cr=2 pr=0 pw=0 time=0 us)
>
As expected? Have you considered that your 'expectation' is wrong?
>
If I issue the same query after creating unique index on hash_cluster_tab(id), the execution plan shows hash access and single I/O (cr = 1).
Does it mean that to have single I/o in a single table hash cluster, we have to create unique index? Won't it create additional overhead of maintaining an index?
What is the second I/O needed for in case unique index is absent?
>
My hypothesis would be that are seeing the effects of having a 'hash collision'; a collision that you caused yourself by the way you defined the table.
Remember when you said this?
>
create cluster hash_cluster_4k
( id number(2) )
size 8192 single table hash is id hashkeys 4 tablespace mssm;
>
You told Oracle there will only be FOUR different IDs used.
And then you said this
>
-- Created a table in cluster with row size such that only one record fits one block and inserted 5 records each with a distinct key value
>
You used FIVE different IDs and only ONE record will fit into each block.
So that record with 'ID=5' is guaranteed to HASH to one of the existing four hash values. And that means you have a 'hash collision'.
The docs explain what happens when you have a 'hash collision'. See the 'Hash Cluster Storage' section in the Database Concepts doc
http://docs.oracle.com/cd/E11882_01/server.112/e25789/tablecls.htm#sthref258
>
Hash Cluster Storage
Oracle Database allocates space for a hash cluster differently from an indexed cluster. In Example 2-9, HASHKEYS specifies the number of departments likely to exist, whereas SIZE specifies the size of the data associated with each department. The database computes a storage space value based on the following formula:
HASHKEYS * SIZE / database_block_size
Thus, if the block size is 4096 bytes in Example 2-9, then the database allocates at least 200 blocks to the hash cluster.
Oracle Database does not limit the number of hash key values that you can insert into the cluster. For example, even though HASHKEYS is 100, nothing prevents you from inserting 200 unique departments in the departments table. However, the efficiency of the hash cluster retrieval diminishes when the number of hash values exceeds the number of hash keys.
>
Using that formula above with HASHKEYS=4, SIZE=8192 and block size=8192 Oracle allocates at least 4 blocks.
The next two paragraphs tell you what happens for a use case like yours: HASH COLLISION
>
To illustrate the retrieval issues, assume that block 100 in Figure 2-7 is completely full with rows for department 20. A user inserts a new department with department_id 43 into the departments table. The number of departments exceeds the HASHKEYS value, so the database hashes department_id 43 to hash value 77, which is the same hash value used for department_id 20. Hashing multiple input values to the same output value is called a hash collision.
When users insert rows into the cluster for department 43, the database cannot store these rows in block 100, which is full. The database links block 100 to a new overflow block, say block 200, and stores the inserted rows in the new block. Both block 100 and 200 are now eligible to store data for either department. As shown in Figure 2-8, a query of either department 20 or 43 now requires two I/Os to retrieve the data: block 100 and its associated block 200. You can solve this problem by re-creating the cluster with a different HASHKEYS value.
>
Note the next to last sentence:
>
As shown in Figure 2-8, a query of either department 20 or 43 now requires two I/Os to retrieve the data: block 100 and its associated block 200.
>
Hmmmm - sounds suspiciously like your use case don't you think?
Try what the doc says in that last sentence and see if it solves your problem:
>
You can solve this problem by re-creating the cluster with a different HASHKEYS value.
>
The parameters you provided and the table example you are using GUARANTEE that if more than FOUR ids are used there will be hash collisions and the result MUST BE what the doc describes. There will NEVER be space in an existing block for a second row so a new block has to be used and that means 'chaining' the blocks to find the one you need: one I/O for each block in the chain.
Jonathan said he could not reproduce your problem but the 'hash' algorithm for his instance might have hashed 'ID=5' to a different value; his 'hash collision' might only occur for ID=2 (or 3 or 4).

Similar Messages

  • Issue with single table hash cluster

    I'm still learning lots about html db so please do bear with me...
    I have a table that is part of a single table hash cluster. The cluster and table are created like so:
    create cluster webmon.owm_system
      db_id number(3),
      env_id number(3)
    size 171
    hashkeys 1009
    single table
    pctfree 2
    pctused 96;
    create table webmon.owm_system
      tier_id number(3) not null,
      host_id number(3) not null,
      port number(4) not null,
      sid varchar2(8) not null,
      admin_user varchar2(32) not null,
      admin_auth varchar2(48) not null,
      primary_dba_id number(3) not null,
      secondary_dba_id number(3) not null,
      primary_bac_id number(3) not null,
      secondary_bac_id number(3) not null,
      version_id number(3) not null,
      log_mode_id number(3) not null,
      db_id number(3) not null,
      env_id number(3) not null,
      admin_conn varchar2(32) null,
      constraint owm_system_pk primary key (db_id, env_id)
    cluster webmon.owm_system
      db_id,
      env_id
    );I have created a form (and report) to view and edit the data in the table. When I click the "Apply Changes" button on the form after editing data, I get an error. The SQL that is sent to the database is incorrect.
    Here is the (reformatted) incorrect SQL that is sent (captured in a database trace file):
    update
      "WEBMON"."OWM_SYSTEM"
    set
      "SECONDARY_DBA_ID" = :DML_BV0001,
      "DB_ID" = :DML_BV0002,
      "DB_ID" = :DML_BV0003,  /* This should not be here */
      "ENV_ID" = :DML_BV0004,
      "ENV_ID" = :DML_BV0005,  /* This should not be here */
      "HOST_ID" = :DML_BV0006,
      "PORT" = :DML_BV0007,
      "SID" = replace(:DML_BV0008,'%null%',null),
      "ADMIN_USER" = replace(:DML_BV0009,'%null%',null),
      "ADMIN_AUTH" = replace(:DML_BV0010,'%null%',null),
      "ADMIN_CONN" = replace(:DML_BV0011,'%null%',null),
      "VERSION_ID" = :DML_BV0012,
      "LOG_MODE_ID" = :DML_BV0013,
      "TIER_ID" = :DML_BV0014,
      "PRIMARY_DBA_ID" = :DML_BV0015,
      "PRIMARY_BAC_ID" = :DML_BV0016,
      "SECONDARY_BAC_ID" = :DML_BV0017
    where
      "DB_ID" = :p_rowid
    and
      "ENV_ID" = :p_rowid2Why are the DB_ID and ENV_ID columns in the statement twice? That is the error.
    Now, if I create the table as just a basic, non-clustered table like this:
    create table webmon.owm_system
      tier_id number(3) not null,
      host_id number(3) not null,
      port number(4) not null,
      sid varchar2(8) not null,
      admin_user varchar2(32) not null,
      admin_auth varchar2(48) not null,
      primary_dba_id number(3) not null,
      secondary_dba_id number(3) not null,
      primary_bac_id number(3) not null,
      secondary_bac_id number(3) not null,
      version_id number(3) not null,
      log_mode_id number(3) not null,
      db_id number(3) not null,
      env_id number(3) not null,
      admin_conn varchar2(32) null,
      constraint owm_system_pk primary key (db_id, env_id)
    );Everything works as expected. The (correct) SQL sent in this case is:
    update
      "WEBMON"."OWM_SYSTEM"
    set
      "SECONDARY_DBA_ID" = :DML_BV0001,
      "DB_ID" = :DML_BV0002,
      "ENV_ID" = :DML_BV0003,
      "HOST_ID" = :DML_BV0004,
      "PORT" = :DML_BV0005,
      "SID" = replace(:DML_BV0006,'%null%',null),
      "ADMIN_USER" = replace(:DML_BV0007,'%null%',null),
      "ADMIN_AUTH" = replace(:DML_BV0008,'%null%',null),
      "ADMIN_CONN" = replace(:DML_BV0009,'%null%',null),
      "VERSION_ID" = :DML_BV0010,
      "LOG_MODE_ID" = :DML_BV0011,
      "TIER_ID" = :DML_BV0012,
      "PRIMARY_DBA_ID" = :DML_BV0013,
      "PRIMARY_BAC_ID" = :DML_BV0014,
      "SECONDARY_BAC_ID" = :DML_BV0015
    where
      "DB_ID" = :p_rowid
    and
      "ENV_ID" = :p_rowid2The "real" system in question has a fairly large number of single table hash clusters. I'm leary of continuing my explorations if there is a problem with using single table hash clusters. On the other hand, I'm quite open to the idea that I've done something wrong!
    Any pointers? Is there anyway to change the SQL that is being generated when using the single table hash cluster? More information needed?
    Thanks,
    Mark

    Mark,
    Can't help with the hash table problem but as a method of dealing with it you could just make a procedure to manage the table.
    Pass the value of :REQUEST (matches value of button) in and you'll be able to modify the tables.
    procedure manage_owm_system (p_request varchar2,db_id number ...)is
    begin
    case p_request
    when 'CREATE' then
    insert
    into ....
    when 'SAVE' then
    update .....
    else
    raise_application_error(-20001,'Unkown request');
    end case;
    end;
    put that in a plsql reqion after submit
    begin
    manage_owm_system(p_request=>:REQUEST,p_dbid=>:P1_DBID .......);
    end;
    You need to create something similar , with out parameters, to populate the items when the pags loads.
    Chris

  • Deadlock when updating different rows on a single table with one clustered index

    Deadlock when updating different rows on a single table with one clustered index. Can anyone explain why?
    <event name="xml_deadlock_report" package="sqlserver" timestamp="2014-07-30T06:12:17.839Z">
      <data name="xml_report">
        <value>
          <deadlock>
            <victim-list>
              <victimProcess id="process1209f498" />
            </victim-list>
            <process-list>
              <process id="process1209f498" taskpriority="0" logused="1260" waitresource="KEY: 8:72057654588604416 (8ceb12026762)" waittime="1396" ownerId="1145783115" transactionname="implicit_transaction"
    lasttranstarted="2014-07-30T02:12:16.430" XDES="0x3a2daa538" lockMode="X" schedulerid="46" kpid="7868" status="suspended" spid="262" sbid="0" ecid="0" priority="0"
    trancount="2" lastbatchstarted="2014-07-30T02:12:16.440" lastbatchcompleted="2014-07-30T02:12:16.437" lastattention="1900-01-01T00:00:00.437" clientapp="Internet Information Services" hostname="CHTWEB-CH2-11P"
    hostpid="12776" loginname="chatuser" isolationlevel="read uncommitted (1)" xactid="1145783115" currentdb="8" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
               <inputbuf>
    UPDATE analyst_monitor SET cam_status = N'4', cam_event_data = N'sales1', cam_event_time = current_timestamp , cam_modified_time = current_timestamp , cam_room = '' WHERE cam_analyst_name=N'ABCD' AND cam_window= 2   </inputbuf>
              </process>
              <process id="process9cba188" taskpriority="0" logused="2084" waitresource="KEY: 8:72057654588604416 (2280b457674a)" waittime="1397" ownerId="1145783104" transactionname="implicit_transaction"
    lasttranstarted="2014-07-30T02:12:16.427" XDES="0x909616d28" lockMode="X" schedulerid="23" kpid="8704" status="suspended" spid="155" sbid="0" ecid="0" priority="0"
    trancount="2" lastbatchstarted="2014-07-30T02:12:16.440" lastbatchcompleted="2014-07-30T02:12:16.437" lastattention="1900-01-01T00:00:00.437" clientapp="Internet Information Services" hostname="CHTWEB-CH2-11P"
    hostpid="12776" loginname="chatuser" isolationlevel="read uncommitted (1)" xactid="1145783104" currentdb="8" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
                <inputbuf>
    UPDATE analyst_monitor SET cam_status = N'4', cam_event_data = N'sales2', cam_event_time = current_timestamp , cam_modified_time = current_timestamp , cam_room = '' WHERE cam_analyst_name=N'12345' AND cam_window= 1   </inputbuf>
              </process>
            </process-list>
            <resource-list>
              <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor" indexname="IX_Clust_scam_an_name_window" id="lock4befe1100" mode="X" associatedObjectId="72057654588604416">
                <owner-list>
                  <owner id="process9cba188" mode="X" />
                </owner-list>
                <waiter-list>
                  <waiter id="process1209f498" mode="X" requestType="wait" />
                </waiter-list>
              </keylock>
              <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor" indexname="IX_Clust_scam_an_name_window" id="lock18ee1ab00" mode="X" associatedObjectId="72057654588604416">
                <owner-list>
                  <owner id="process1209f498" mode="X" />
                </owner-list>
                <waiter-list>
                  <waiter id="process9cba188" mode="X" requestType="wait" />
                </waiter-list>
              </keylock>
            </resource-list>
          </deadlock>
        </value>
      </data>
    </event>

    To be honest, I don't think the transaction is necessary, but the developers put it there anyway. The select statement will put the result cam_status
    into a variable, and then depends on its value, it will decide whether to execute the second update statement or not. I still can't upload the screen-shot, because it says it needs to verify my account at first. No clue at all. But it is very simple, just
    like:
    Clustered Index Update
    [analyst_monitor].[IX_Clust_scam_an_name_window]
    cost: 100%
    By the way, for some reason, I can't find the object based on the associatedObjectId listed in the XML
    <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor"
    indexname="IX_Clust_scam_an_name_window" id="lock4befe1100" mode="X" associatedObjectId="72057654588604416">
    For example: 
    SELECT * FROM sys.partition WHERE hobt_id = 72057654588604416
    This return nothing. Not sure why.

  • Hash clustered table and freelist

    We want to use hash clustered table to store a lookup table, that table has 300M rows, and every day it will get 100K rows. If using clustered table, we could get a best performance for lookup. My concern is the insert. For normal table, we could use freelist to let different transaction to insert into different block. But for clustered table, many transactions will insert into the same block as their hashed value will locate into the same block. And seems the concept of freelist will not apply to clustered table as a transaction has to operation against a specific block instead of a any-is-ok block

    For the insert operation, things will get worse when use a ID as the hash function, as the ID will increase 1 by 1, so most likely it will be inserted into the same block.
    If using the default hash function, we could avoid this problem, but oracle suggests to use
    "hash is HASH_KEY" when the id is distinct.

  • Recover a single table using RMAN

    Hi,
    I'm working on an Oracle Database 11g Release 11.1.0.6.0 - 64bit Production With the Real Application Clusters option.
    I did a bad update on a table.
    I have a full backup level 0 before the update
    Is it possibile to recover the single table in an instant before the update using RMAN?
    Thanks in advance.
    Samuel

    Hi Samuel,
    How long ago was the update committed? What's the value of undo_retention?
    If the undo has not yet expired, the easiest way to recovery is through flashback query. (Note that flashback database does not have to be enabled for flashback query to work.)
    See MOS Doc ID 238674.1.
    If that's not a possibility, and flashback database is not enabled, the only other option is to do an out-of-place restore, of SYSTEM, UNDO, and tablespace containing the table you want to recover, and recover to point in time before the update. Then, export table, drop the database, and import table into your primary database.
    Hope that helps,
    -Mark

  • Table Alias for a single table query

    Hi,
    What is the difference between using table alias and not using for a query involving single table.
    Say
    select empno, ename from emp where empno = 1000;
    select e.empno,e.ename from emp where e.empno = 1000;
    select 1 from emp e where e.empno = 1000;
    how above three queries shall be parsed/executed. Can anyone please explain the process ......

    Since the 3rd query doesn't access any column values the execution differs from the others:
    SQL>  explain plan for select empno, ename from emp where empno = 1000
    Explain complete.
    SQL>  select * from table(dbms_xplan.display)
    PLAN_TABLE_OUTPUT                                                                                  
    Plan hash value: 2949544139                                                                        
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |             
    |   0 | SELECT STATEMENT            |        |     1 |    10 |     1   (0)| 00:00:01 |             
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    10 |     1   (0)| 00:00:01 |             
    |*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |             
    Predicate Information (identified by operation id):                                                
       2 - access("EMPNO"=1000)                                                                        
    14 rows selected.
    SQL>  truncate table plan_table
    Table truncated.
    SQL>  explain plan for select 1 from emp e where e.empno = 1000
    Explain complete.
    SQL>  select * from table(dbms_xplan.display)
    PLAN_TABLE_OUTPUT                                                                                  
    Plan hash value: 56244932                                                                          
    | Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |                       
    |   0 | SELECT STATEMENT  |        |     1 |     4 |     0   (0)| 00:00:01 |                       
    |*  1 |  INDEX UNIQUE SCAN| PK_EMP |     1 |     4 |     0   (0)| 00:00:01 |                       
    Predicate Information (identified by operation id):                                                
       1 - access("E"."EMPNO"=1000)                                                                    
    13 rows selected.

  • Cluster tables , pool tables ,hashed tables?

    give me the examles of cluster and pool tables  & hashed tables ?

    <b>I. Transparent tables (BKPF, VBAK, VBAP, KNA1, COEP)</b>
    Allows secondary indexes (SE11->Display Table->Indexes)
    Can be buffered (SE11->Display Table->technical settings) Heavily updated tables should not be buffered.
    <b>
    II. Pool Tables (match codes, look up tables)</b>
    Should be accessed via primary key or
    Should be buffered (SE11->Display Table->technical settings)
    No secondary indexes
    Select * is Ok because all columns retrieved anyway
    <b>III. Cluster Tables (BSEG,BSEC)</b>
    Should be accessed via primary key - very fast retrieval otherwise very slow
    No secondary indexes
    Select * is Ok because all columns retrieved anyway. Performing an operation on multiple rows is more efficient than single row operations. Therefore you still want to select into an internal table. If many rows are being selected into the internal table, you might still like to retrieve specific columns to cut down on the memory required.
    Statistical SQL functions (SUM, AVG, MIN, MAX, etc) not supported
    Can not be buffered
    <b>IV. Buffered Tables (includes both Transparent & Pool Tables)</b>
    While buffering database tables in program memory (SELECT into internal table) is generally a good idea for performance, it is not always necessary. Some tables are already buffered in memory. These are mostly configuration tables. If a table is already buffered, then a select statement against it is very fast. To determine if a table is buffered, choose the 'technical settings' soft button from the data dictionary display of a table (SE12). Pool tables should all be buffered.
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Creation of SAP Query in SQ02 with Single Table With Condition

    Hi All,
    I want to Create SAP Query in SQ02 using single Table MCHA.
    ii) I dont want all entries of MCHA Table I mean , I have to apply some Condition on this Table.
    i.e  Suppose I am having actual data in MCHA table is like this for Material M1.
    Plant    Material   Batch   BatchCreationdate
    P1          M1         B1       20.06.2007
    P2          M1         B1       04.05.2009
    P3          M1         B1       04.05.2009
    But I want the Output of SAP Query is like this:
       Material   Batch   BatchCreationdate
          M1         B1       20.06.2007
    That is irrespective of Plant if Material & Batch are equal ---> 1st record with Lowest date shoud get at the output.
    Please help me How write the code on single table in the SAP Query.
    Thanks,
    Kiran Manyam

    Hi,
    Your query should be like this:
    Select MATNR CHARG HSDAT
    from MCHA
    into table t_mcha
    where matnr = Materlal number from selection screen.
    The structure of t_mcha should contain the fields that you select.
    Then sort the table by date ascending
    Sort t_mcha by HSDAT.
    Hope this solves your problem.
    Thanks,
    Sowmya

  • How to display data from 2 different groups in a single table

    Hi,
    Following is the requirement:
    The XML Content is below
    ListOf_ssAssetMgmtAsset>
    -<ssAssetMgmtAsset>
    <ssAccountName>1-1D09-83031</ssAccountName>
    <ssAccountPrimaryCountry>USA</ssAccountPrimaryCountry>
    <ssAssetNumber>13111027</ssAssetNumber>
    <ssNaiAssetNumber>123</ssNaiAssetNumber>
    <ssNaiGrantNumber>ABC</ssNaiGrantNumber>
    <ssNaiProductType>System Security Software</ssNaiProductType>
    <ssNaiSuperceded>123</ssNaiSuperceded>
    <ssProductDescription>Upgrade extract local DB</ssProductDescription>
    <ssProductName>1-1M5H-296</ssProductName>
    <ssStatus>ABC</ssStatus>
    <ssId>1X-ZY</ssId>
    <ssCreated>01/01/1980</ssCreated>
    <ssUpdated>01/01/1980</ssUpdated>
    <ssCreatedBy>1X-ZY</ssCreatedBy>
    <ssUpdatedBy>1X-ZY</ssUpdatedBy>
    -<ListOf_ssAgreementEntitlement>
    -<ssAgreementEntitlement>
    <ssEntitlementEndDate>16/12/2009</ssEntitlementEndDate>
    <ssEntitlementStartDate>16/11/2009</ssEntitlementStartDate>
    <ssEntitlementType>Services</ssEntitlementType>
    <ssNaiQuantity>2</ssNaiQuantity>
    </ssAgreementEntitlement>
    </ListOf_ssAgreementEntitlement>
    -<ListOf_ssAgreementEntitlement>
    -<ssAgreementEntitlement>
    <ssEntitlementEndDate>10/12/2009</ssEntitlementEndDate>
    <ssEntitlementStartDate>10/11/2009</ssEntitlementStartDate>
    <ssEntitlementType>ServicePortal</ssEntitlementType>
    <ssNaiQuantity>1</ssNaiQuantity>
    </ssAgreementEntitlement>
    </ListOf_ssAgreementEntitlement>
    </ssAssetMgmtAsset>
    </ListOf_ssAssetMgmtAsset>
    The data needs to be displayed in the below manner where first grouping is by Account Country, then by Account Name. Then the table with 9 columns where in the first 5 columns are from first group and the next 4 are from second group.
    Account Country
    Account Name
         ProductType     Grant #     Asset #     Product SKU Product Name Entitlement Type Quantity /Nodes     EntitlementStart Date     Entitlement EndDate
    I have the coding as
    first for loop: <?for-each-group:ssAssetMgmtAsset;./ssAccountPrimaryCountry?>
    second for loop: <?for-each-group:current-group();./ssAccountName?>
    third which is for the table : <?for-each:current-group()?>
    I close the above grp after product description.
    One table with the first 5 columns and below second table is placed adjacent to the first to display the 4 columns with the grp <?for-each:ssAgreementEntitlement?>
    how do I get all the 9 columns in a single row in a single table.
    Any help is appreciated.
    thanks

    What is the lnk between the two
    ssAssetMgmtAsset and ssAgreementEntitlement ?
    you want to display all the ssAgreementEntitlement for every ssAssetMgmtAsset group ?
    there shud be a link between them, you have link them and display.

  • Why do we create multiple aliases to a single table?

    <h4>{color:#0000ff}Hi,{color}</h4>
    <h4></h4>
    <h4></h4>
    <h4>{color:#0000ff} Why do we create multiple aliases to a single table in the same query?{color}</h4>
    <h4></h4>
    <h4></h4>
    <h4>{color:#0000ff}{color:#000000}For Ex: {color}{color}</h4>
    <h4>
    {color:#000000}select name,address,phone, from emp e, emp e1{color}</h4>
    <h4></h4>
    <h4>{color:#000000}where e.empid = e1.empid;{color}</h4>
    <h4>
    {color:#0000ff}ofcourse the above query's where condition is not correct, but i am giving as an example only{color}</h4>
    <h4>{color:#0000ff}I have seen similar kind of queries where a single table name is aliased 10 times in the same query{color}</h4>
    <h4>{color:#0000ff}can someone help me to understand the logic behind it?{color}</h4>
    <h4>{color:#0000ff}Thanks in advance{color}</h4>
    <h4>{color:#0000ff}greddy.{color}</h4>
    Edited by: greddy on Oct 24, 2008 2:46 AM

    Hi,
    When you say
    FROM    emp  e
    ,       emp  e1you are using two copies of the same table.
    Can you imagine using two copies of the same book at the same time?
    Say you see a word (like "hyrax") that you don't know. You might look up that word in the dictionary.
    The English sentence "Open the dictionary to the page containing the new word." is like this SQL query:
    FROM    dictionary
    WHERE   :unknown_word  BETWEEN low_guide_word and high_guide_wordWhat if you saw that word while reading a book (let's call it book_a).
    You might want to leave book_a open, and place the dictionary beside book_a, so you can easily compare how the word is used in book_a with the definition in the dictionary.
    This corresponds to joining two tables in SQL:
    FROM    book_a     
    JOIN    dictionary  ON unknown_word BETWEEN low_guide_word AND high_guide_word
    WHERE   book_a.page  = whatever  -- NOTE: both tables have a column called pageor you can use aliases for one or both of the tables
    FROM    book_a      a
    JOIN    dictionary  d  ON a.unknown_word BETWEEN d.low_guide_word AND d.high_guide_word
    WHERE   a.page  = whatever  -- NOTE: both tables have a column called pageNow, imagine that book_a is itself the dictionary. Say you saw the word "hyrax" while you were looking up another word, "ibex".
    You can do a side-by-side comparison, as above, if you have two copies of the dictionary. Leave one copy open to "ibex", and open the other copy to "hyrax".
    This corresponds to a self-join in SQL:
    FROM    dictionary  a
    JOIN    dictionary  d  ON a.unknown_word BETWEEN d.low_guide_word AND d.high_guide_word
    WHERE   a.page  = whatever  -- NOTE: both tables have a column called pageNotice that this last bit of code is identical to the previous one, except that book_a is replaced with dictionary.
    In this case, you must you a table alias, at least for one copy. It wouldn't make any sense to say "Leave the dictionary open to "ibex" and open the dictionary to "hyrax". You have to have some unique way of referring to each copy, such as "Leave the dictionary on my left open to "ibex" and open the dictionary on my right to "hyrax"."

  • Multiple clob fields in a single table

    Are there any known performance issues associated with having 4 CLOB fields in a single table... the table as such will be relatively small.. like 100 MB... with most rows being << 50k.

    Not really. If you need 4 CLOB columns and it makes sense to have alll the columns in a single table, go for it.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to restore a single table from a DP Export from a different schema?

    Environment:
    Oracle 11.2.0.3 EE on Solaris
    I was looking at the documentation on DP Import trying to find the correct syntax to import a single table from a DP Export of a different schema.
    So, I want to load table USER1.TABLE1 into USER2.TABLE1 from a DP Export.
    Looking at the REMAP_TABLE options:
    REMAP_TABLE=[schema.]old_tablename[.partition]:new_tablename
    OR
    REMAP_TABLE=[schema.]old_tablename[:partition]:new_tablenameI can't see where to specify the target schema name. The examples had the new table name residing in the same schema with just a new name.
    I looked at the REMAP_SCHEMA but the docs say that will import the entire schema into the new schema and I only want one (1) table.
    Any suggestions are most welcome!
    -gary

    I thought I tried that combination and it seemed to me that the REMAP_SCHEMA somehow over-rode the TABLES= parameter >and started loading all the objects.If it does fail (and it should not) then please post the details here and I will try to see what is happening.
    Let me get back into the sandbox and try it again. I admit I was in a bit of a hurry when I did it the first time.We are all in a hurry, no worries. If it fails, please post the details and the log file.
    Does it make any sense that one parameter would override another?No, this should never happen. We have tons of checks to make sure the job can't have multiple meanings. For example, you can't say
    full=y schemas=foo --- Which do you want, a full export or a list of schema exports, etc.
    Your suggestion was the first thing I thought would work.This should work. If not, please post the log file with the command and the results.
    Dean
    Thanks again for the help and stay tuned for my new attempt.
    -gary

  • Two Fields in a Single Table

    Hello All,
    I'm a newbie to the forum & to Crystal(9), I've searched the forum and ca't exactly find an answer to my question:
    My goal is to be able to pull the Company Member Type & the Contact Member Type as part of the same report in the selection criteria.
    My problem is: They both reside in the same table...
    The question is: "how to be able to pull the info?"
    If I need to provide more or clearer info pleasde let me know.  Any help is appreciated.
    Lost in DC - DJ

    If you have a single table datasource record duplication wouldn't be a result of the select expert. In fact, I can't think of a case where a single table datasource could possibly duplicate records.
    The duplicates must be the result of a join.
    To answer your initial question, the select expert you enter is subjected, in its entirety, to each record in the joined tables.
    The problem that I see with the above suggestion relates to precedence.
    This:
    cond 1 AND cond 2 AND cond 3 OR cond 4
    Is not this:
    cond 1 AND cond 2 AND (cond 3 OR cond 4)
    In the case of the non-paren-ed select statement, it will return records that satisfy ALL of the AND conditions OR just the or condition.
    In the second case, it will return all records that satisfy condition 1 and condition 2 AND either condition 3 or condition 4.
    Try bracketing the ored conditions from the same table. That should solve your select problem, but not the duplication problem.

  • 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

  • Adding a single table without a logical join to another table (OBIEE 10g)

    Sometimes I want to just display a single table without a logical join to another table in the repository. However, everytime I move it to the Business Model and Mapping layer and perform a Global Consistency Check, it tells me that it needs a logical join and I am forced to create another table to join to it. Thus creating a dimension-fact relationship. There are times I don't need this relationship and just want to display some data. Is there anyway to get around this?
    Thanks in advance!

    Yes,You have to create a join.You cannot take single table to BMM layer.You can create an alias of the table.Join this alias and base table through any common column and take both tables to BMM and desired table to presentation layer.
    Another way is to create a view in physcial layer.Write a select statement like
    Select primary_key from Table
    Where primary_key is primary key of base table.Join this view ith base table and repeat the steps defined for Alias.
    Regards,
    Sandeep

Maybe you are looking for

  • Animated gif creation...

    Hi - I realize this is not the right forum, but I couldn't find one for Fireworks - and it is related to web development... so... I have used Image Ready for years now, and love the simplicity of it! Creating an animated gif is a very painless proces

  • My iPad it telling me that this device is already associated with an Apple ID

    MMy iPad is telling me that my device is already associated with an Apple ID 

  • Printing double sided

    Hi, I just got a MacBook Pro and am finding I can't print double sided. My old PC prints double sided to the same printer (an HP LaserJet 4250dtn) so that shouldn't be a problem, but there doesn't seem to be an option in my Print window to print doub

  • File Polling Error Handling

    Hello, I want to know how I can capture the error message in my BPEL process when I submit a wrong xml file to file adapter. I can process an xml file because the xsd is validated, but I want to know how to capture the error message (Error while tran

  • Many Ship to party assigned to 1 sold to party

    Hi guru's Can any 1 tell me what is the maximum number of ship to parties assigned to 1 sold to party. Also let us know if there is  limitation then what is the solution to extened the same.