Getting same index size despite different table size

Hello,
this question arose from a different thread, but touches a different problem, which is why I have decided to post it as a separate thread.
I have several tables of 3D points.
The points roughly describe the same area but in different densities, which means the tables are of different sizes. The smallest contains around 3million entries and the largest around 37 million entries.
I applied an index with
CREATE INDEX <index name>
ON <table name>(<column name>)
INDEXTYPE is MDSYS.SPATIAL_INDEX
PARAMETERS('sdo_indx_dims=3');
My problem is that I am trying to see how much space the index occupies for each table.
I used the following syntax to get the answer to this:
SELECT usim.sdo_index_name segment_name, bytes/1024/1024 segment_size_mb
FROM user_segments us, user_sdo_index_metadata usim
WHERE usim.SDO_INDEX_NAME = <spatial index name>
AND us.segment_name = usim.SDO_INDEX_TABLE;
(thanks Reggie for supplying the sql)
Now, the curious thing is that in all cases, I get the answer
SEGMENT_NAME SEGMENT_SIZE_MB
LIDAR_POINTS109_IDX .0625
(obviously with a different sement name in each case).
I tried to see what an estimated index size would be with
SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE
And I get estimates ranging from 230MB in the case of 3million records up to 2.9 for the case of 37million records.
Does anyone have an idea why I am not getting a different actual index size for the different tables?
Any help is greatly appreciated!!!
Cheers,
F.

It looks like your indexes didn't actually create properly. Spatial indexes are a bit different to 'normal' indexes in this regard. A BTree index will either create or not. However, when creating a spatial index, something may fail, but the index structure will remain and it will appear to be valid according to the data dictionary.
Consider the following example in which the SRID has a problem:
SQL> CREATE TABLE INDEX_TEST (
  2  ID NUMBER PRIMARY KEY,
  3  GEOMETRY SDO_GEOMETRY);
Table created.
SQL>
SQL> INSERT INTO INDEX_TEST (ID, GEOMETRY) VALUES (1,
  2  SDO_GEOMETRY(2001, 99999, SDO_POINT_TYPE(569278.141, 836920.735, NULL), NULL, NULL)
  3
SQL> INSERT INTO user_sdo_geom_metadata VALUES ('INDEX_TEST','GEOMETRY',
  2     MDSYS.SDO_DIM_ARRAY(
  3     MDSYS.SDO_DIM_ELEMENT('X',0, 1000, 0.0005),
  4     MDSYS.SDO_DIM_ELEMENT('Y',0, 1000, 0.0005)
  5  ), 88888);
1 row created.
SQL>
SQL> CREATE INDEX INDEX_TEST_SPIND ON INDEX_TEST(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
CREATE INDEX INDEX_TEST_SPIND ON INDEX_TEST(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-13249: SRID 88888 does not exist in MDSYS.CS_SRS table
ORA-29400: data cartridge error
Error - OCI_NODATA
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
SQL> SELECT usim.sdo_index_name segment_name, bytes/1024/1024 segment_size_mb,
  2  usim.sdo_index_status
  2  FROM user_segments us, user_sdo_index_metadata usim
  3  WHERE usim.SDO_INDEX_NAME = 'INDEX_TEST_SPIND'
  4  AND us.segment_name = usim.SDO_INDEX_TABLE;
SEGMENT_NAME                     SEGMENT_SIZE_MB SDO_INDEX_STATUS
INDEX_TEST_SPIND                           .0625 VALID
1 row selected.
SQL>When you ran the CREATE INDEX statement did it say "Index created." afterwards or did you get an error?
Did you run the CREATE INDEX statement in SQL*Plus yourself or was it run by some software?
I suggest you drop the indexes and try creating them again. Watch out for any errors. Chances are its an SRID issue.

Similar Messages

  • Same index name for different tables in different schema

    Just a quick query
    Can two tables present in different schema of same database has same index name ?
    Will there be any problem?
    Thanks

    And just a quick answer:
    859486 wrote:
    Just a quick query
    Can two tables present in different schema of same database has same index name ?Yes.
    >
    Will there be any problem?No.
    >
    Thanks

  • Index size increases than table size

    Hi All,
    Let me know what are the possible reasons for index size greater than the table size and in some cases index size smaller than table size . ASAP
    Thanks in advance
    sherief

    hi,
    The size of a index depends how inserts and deletes occur.
    With sequential indexes, when records are deleted randomly the space will not be reused as all inserts are in the leading leaf block.
    When all the records in a leaf blocks have been deleted then leaf block is freed (put on index freelist) for reuse reducing the overall percentage of free space.
    This means that if you are deleting aged sequence records at the same rate as you are inserting, then the number of leaf blocks will stay approx constant with a constant low percentage of free space. In this case it is most probably hardly ever worth rebuilding the index.
    With records being deleted randomly then, the inefficiency of the index depends on how the index is used.
    If numerous full index (or range) scans are being done then it should be re-built to reduce the leaf blocks read. This should be done before it significantly affects the performance of the system.
    If index access’s are being done then it only needs to be rebuilt to stop the branch depth increasing or to recover the unused space
    here is a exemple how index size can become larger than table size:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Connected as admin
    SQL> create table rich as select rownum c1,'Verde' c2 from all_objects;
    Table created
    SQL> create index rich_i on rich(c1);
    Index created
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 1179648 144 9
    INDEX 1179648 144 9
    SQL> delete from rich where mod(c1,2)=0;
    29475 rows deleted
    SQL> commit;
    Commit complete
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 1179648 144 9
    INDEX 1179648 144 9
    SQL> insert into rich select rownum+100000, 'qq' from all_objects;
    58952 rows inserted
    SQL> commit;
    Commit complete
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 1703936 208 13
    INDEX 2097152 256 16
    SQL> insert into rich select rownum+200000, 'aa' from all_objects;
    58952 rows inserted
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 2752512 336 21
    INDEX 3014656 368 23
    SQL> delete from rich where mod(c1,2)=0;
    58952 rows deleted
    SQL> commit;
    Commit complete
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 2752512 336 21
    INDEX 3014656 368 23
    SQL> insert into rich select rownum+300000, 'hh' from all_objects;
    58952 rows inserted
    SQL> commit;
    Commit complete
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 3014656 368 23
    INDEX 4063232 496 31
    SQL> alter index rich_i rebuild;
    Index altered
    SQL> select segment_type,bytes,blocks,extents from user_segments where segment_name like 'RICH%';
    SEGMENT_TYPE BYTES BLOCKS EXTENTS
    TABLE 3014656 368 23
    INDEX 2752512 336 21
    SQL>

  • Best practice for a same query against 2 different tables

    Hello all,
    I want to extract info about tablespaces storage, both permanent and temporary. For that I use 2 different cursors that do exactly the same query but against a different table (dba_data_files and dba_temp_files).
    CURSOR permanentTBSStorageInfo (tablespaceName VARCHAR2) IS
    SELECT file_name, bytes, autoextensible, maxbytes, increment_by
    FROM dba_data_files
    WHERE tablespace_name = tablespaceName;
    CURSOR temporaryTBSStorageInfo (tablespaceName VARCHAR2) IS
    SELECT file_name, bytes, autoextensible, maxbytes, increment_by
    FROM dba_temp_files
    WHERE tablespace_name = tablespaceName;
    First I'm bothered that I have to use 2 cursors to execute the same query against 2 different tables. Is there no another way around?
    Then I fetch the results of this cursors in 2 different loops because I didn't find a way to dynamically call the cursors. I am looking for best practice here, knowing that I will do the same parsing against the results of the 2 cursors.
    Thank you,

    Hi
    Check whether the below query is helpful or not
    select      fs.tablespace_name "Tablespace",
         fs.tempspace "Temp MB",
         df.totalspace "Total MB"
         from
         (select
         tablespace_name,
         round(sum(bytes) / 1048576) TotalSpace
         from
         dba_data_files
         group by
         tablespace_name
         ) df,
         (select
         tablespace_name,
         round(sum(bytes) / 1048576) tempSpace
         from
         dba_temp_files
         group by
         tablespace_name
         ) fs
         where
         df.tablespace_name = fs.tablespace_name;
    Thanks

  • Index size greater than table size

    HI ,
    While checking the large segments , I came to know that index HZ_PARAM_TAB_N1 is larger than table HZ_PARAM_TAB . I think it's highly fragmented and requires defragmentation . Need your suggestion on the same that how can I collect more information on the same . Providing you more information .
    1.
    select sum(bytes)/1024/1024/1024,segment_name from dba_segments group by segment_name having sum(bytes)/1024/1024/1024 > 1 order by 1 desc;
    SUM(BYTES)/1024/1024/1024 SEGMENT_NAME
    81.2941895 HZ_PARAM_TAB_N1
    72.1064453 SYS_LOB0000066009C00004$$
    52.7703857 HZ_PARAM_TAB
    2. Index code
    <pre>
    COLUMN_NAME COLUMN_POSITION
    ITEM_KEY 1
    PARAM_NAME 2
    </pre>
    Regards
    Rahul

    Hi ,
    Thanks . I know that rebuild will defragment it . But as I'm on my new site , I was looking for some more supporting information before drafting the mail on the same that it requires re org activity .It's not possible for an index to have the size greater than tables as it contains only 2 columns values + rowid . Whereas tables contains 6 columns .
    <pre>
    Name      Datatype      Length      Mandatory      Comments
    ITEM_KEY      VARCHAR2      (240)      Yes      Unique identifier for the event raised
    PARAM_NAME      VARCHAR2      (2000)      Yes      Name of the parameter
    PARAM_CHAR      VARCHAR2      (4000)      
         Value of the parameter only if its data type is VARCHAR2.
    PARAM_NUM      NUMBER      
         Value of the parameter only if its data type is NUM.
    PARAM_DATE      DATE      
         Value of the parameter only if its data type is DATE.
    PARAM_INDICATOR      VARCHAR2      (3)      Yes      Indicates if the parameter contains existing, new or >replacement values. OLD values currently exist. NEW values create initial values or replace existing values.</pre>
    Regds
    Rahul

  • Index size greated then Table Size

    Hi all,
    We are running BI7.0 in our environment.
    One of the tables' index size is much greated than the table itself. The Details are listed below:
    Table Name: RSBERRORLOG
    Total Table Size: 141,795,392  KB
    Total Index Size: 299,300,576 KB
    Index:
    F5: Index Size / Allocated Size: 50%
    Is there any reason that the index should grow more than Table? If so, would Reorganizing index help and if this can be controlled?
    Please letme know on this as I am not very clear on DB much.
    Thanks and Regards,
    Raghavan

    Hi Hari
    Its basically degenerated index.  You can follow the below steps
    1. Delete some entries from RSBERRORLOG.
    BI database growing at 1 Gb per day while no data update on ECC
    2. Re-organize this table from BRSPACE . Now the size of the table would be very less.  I do not remember if this table has a LONG RAW field ( in that case export /import) of this table would be required.   ---Basis job
    3. Delete and recreate Index on this table
    You will gain lot of space.
    I assumed you are on Oracle.
    More information on reoganization  is LINK: [Reorg|TABLE SPACE REORGANIZATION !! QUICK EXPERT INPUTS;
    Anindya
    Regards
    Anindya

  • LOAD vs OVERWRITE INSERT PRODUCE DIFFERENT TABLE SIZE!!

    Hi again!
    Here is another issue I don't understand why happens:
    The size of the table doubles if I load the data with INSERT OVERWRITE vs LOAD. As follows is an illustration of the problem:
    I created a table "item". Loaded the data from item.dat (aprox 28MB). After that what happens is that the file item.dat will be moved to hive/warehouse and off course the size remains the same
    Now if I create another table "item2" same as item and then load the data from item to item2 with the following command:
    INSERT OVERWRITE TABLE item2 SELECT * FROM item
    the size of table item2 is double of item (aprox 55MB)
    Why does this happen? And is there any way to avoid it?
    And the situation escalates as the size of the data grows.
    ps. this is only to illustrate the problem. In practice I am interested for pre-joining tables but INSERT OVERWRITE increases the size of the joined table drastically (Actual problem: 4GB joined with 28MB gives 18GB)
    Thank you!

    Latest update on the issue:
    I tested on cloudera as well and it is the same behavior: As follows are some details after running describe formatted <table_name> :
    item (with LOAD):
    33 Table Type: MANAGED_TABLE NULL
    34 Table Parameters: NULL NULL
    35 COLUMN_STATS_ACCURATE true
    36 numFiles 1
    37 numRows 0
    38 rawDataSize 0
    39 totalSize 28855325
    40 transient_lastDdlTime 1427988576
    41 NULL NULL
    42 # Storage Information NULL NULL
    43 SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe NULL
    44 InputFormat: org.apache.hadoop.mapred.TextInputFormat NULL
    45 OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat NULL
    46 Compressed: No NULL
    item2 (with INSERT OVERWRITE):
    33 Table Type: MANAGED_TABLE NULL
    34 Table Parameters: NULL NULL
    35 COLUMN_STATS_ACCURATE true
    36 numFiles 1
    37 numRows 102000
    38 rawDataSize 52058005
    39 totalSize 52160005
    40 transient_lastDdlTime 1427990208
    41 NULL NULL
    42 # Storage Information NULL NULL
    43 SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe NULL
    44 InputFormat: org.apache.hadoop.mapred.TextInputFormat NULL
    45 OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat NULL
    46 Compressed: No NULL
    And now I don’t understand why the number of rows is 0 for item. When I query it returns 102000 rows

  • How to get row index in dynamically populated table?

    Hi,
    I am following example given in http://balusc.xs4all.nl/srv/dev-jep-dat.html to Dynamically populate datatable. How can I get row index while populating table in populateDynamicDataTable() method
    private List myList;
    private String[] headers; // Optional.
    private HtmlDataTable dynamicDataTable;
    // Actions ----------------------------------------------------------
    public void loadMyList() {
    // Set headers (optional).
    headers = new String[] {"header1", "header2", "header3"};
    // Set rows. This is a stub example, just do your dynamic thing.
    String[] row1 = {"ID1", "Name1", "Value1"};
    String[] row2 = {"ID2", "Name2", "Value2"};
    String[] row3 = {"ID3", "Name3", "Value3"};
    // Convert rows to List and set the List.
    myList = new ArrayList();
    myList.add(Arrays.asList(row1));
    myList.add(Arrays.asList(row2));
    myList.add(Arrays.asList(row3));
    public void populateDynamicDataTable() {
    //*********************** I want current row in this method *************//
    // Any columns?
    if (myList != null && myList.size() > 0) {
    dynamicDataTable = new HtmlDataTable();
    // Get amount of columns.
    int columns = ((List) myList.get(0)).size();
    // Set columns.
    for (int i = 0; i < columns; i++) {
    // Set header (optional).
    UIOutput header = new UIOutput();
    header.setValue(headers);
    // Set output.
    UIOutput output = new UIOutput();
    ValueBinding myItem =
    FacesContext
    .getCurrentInstance()
    .getApplication()
    .createValueBinding("#{myItem[" + i + "]}");
    output.setValueBinding("value", myItem);
    // Set column.
    UIColumn column = new UIColumn();
    column.setHeader(header);
    column.getChildren().add(output);
    // Add column.
    dynamicDataTable.getChildren().add(column);
    // Getters ----------------------------------------------------------
    public List getMyList() {
    return myList;
    public HtmlDataTable getDynamicDataTable() {
    if (dynamicDataTable == null) {
    loadMyList(); // Reload to get most recent data.
    populateDynamicDataTable();
    return dynamicDataTable;
    // Setters ----------------------------------------------------------
    public void setMyList(List myList) {
    this.myList = myList;
    public void setDynamicDataTable(HtmlDataTable dynamicDataTable) {
    this.dynamicDataTable = dynamicDataTable;
    I have tried dynamicDataTable.getRowIndex, but it returns -1
    Is there any other way?
    Thanks ,
    Chitra.

    When you dynamically populate a datatable, you're populating the columns, not the actual rows.
    Just add EL to the styleClass attribute, like:styleClass="#{myBean.myTable.rowIndex == 1 ? 'highlightedClass' : 'defaultClass'}"where 'myTable' refers to a HtmlDataTable property in the backing bean.

  • How to get only column names from different tables as single table columns

    Hi All,
       I have one requirement in which we want only column names from different tables.
    for example :
     I have three tables T1 ,T2, T3 having
      col1 clo2 clo3 -->  T1 , 
      col3 col5 ,clo6 --> T2 ,
      Clo6 col8 col9 --> T3
    columns i want to get only all  Column names from all table as single Resultset not any data from that how can i get that empty resultset 
    because this empty result i want to bind in datagridview(front end) as Empty resultset 
    Please tell me anyways to do this
    Niraj Sevalkar

    If I understand you want an empty result set, just with metadata. SET FMTONLY do the trick:
    SET FMTONLY ON
    SELECT Col1, Col2, Col3, ....., Coln
    FROM
    T1 CROSS JOIN T2 CROSS JOIN T3
    SET FMTONLY OFF
    Another alternative is to include an imposible contition
    SELECT Col1, Col2, Col3, ....., Coln
    FROM
    T1 CROSS JOIN T2 CROSS JOIN T3
    WHERE 1 = 0
    If you are using a SqlDataAdapter in your client application. You can use the FillSchema method. the select command may be any select statement that returns the columns you want. Under the covers FillSchema will call SET FMTONLY ON.
    If you are using SqlCommand.ExecuteReader you can pass SchemaOnly to CommandBehavior argument. SET FMTONLY ON is called under the covers. Again the select command may be any select statement that returns the columns you want.
    "No darás tropezón ni desatino que no te haga adelantar camino" Bernardo Balbuena

  • Sum of same fields in two different tables

    Hi ,
    I am facing a problem, hope anyone would help
    I have two tables.. here is the sample data..
    create table t1
    (item_ID NUMBER(2),
    book_ID NUMBER(2),
    price NUMBER(2))
    insert into t1 (item_ID, book_ID, price) values (1,1,60);
    insert into t1 (item_ID, book_ID, price) values (1,2,70);
    insert into t1 (item_ID, book_ID, price) values (1,3,80);
    insert into t1 (item_ID, book_ID, price) values (2,1,10);
    insert into t1 (item_ID, book_ID, price) values (2,1,20);
    insert into t1 (item_ID, book_ID, price) values (1,3,40);
    create table t2
    (item_ID NUMBER(2),
    book_ID NUMBER(2),
    price NUMBER(2))
    insert into t2 (item_ID, book_ID, price) values (1,1,89);
    insert into t2 (item_ID, book_ID, price) values (1,2,29);
    insert into t2 (item_ID, book_ID, price) values (1,3,99);
    insert into t2 (item_ID, book_ID, price) values (2,1,55);
    insert into t2 (item_ID, book_ID, price) values (2,1,90);
    insert into t2 (item_ID, book_ID, price) values (1,3,10);
    as you can see, both tables have the same column names with different data. what
    I require is that i need to calculate the SUM of price grouped by book_id from
    both the tables in a single SQL statement output.
    so my required output is this:
    BOOK_ID SUM(PRICE)
    1 323
    2 99
    3 229
    where the SUM(price) for each book_id is for all the books in both the tables
    where book_id = 1 and then 2 in the second row and then 3 in the third row.
    Would anyone please help, as I am unable to write the query for this.?
    Thanks,
    Sonali.

    <quote>I was just curious if we can do that by some other SQl query and using UNION ALL operator...</quote>
    Of course there are other ways to do it ... but not necessarily better ... just to satisfy your curiosity:
    flip@FLOP> select book_id,sum(price) from t1 group by book_id;
       BOOK_ID SUM(PRICE)
             1    5898240
             2    4587520
             3    7864320
             4    2621440
    Elapsed: 00:00:01.02
    flip@FLOP> select book_id,sum(price) from t2 group by book_id;
       BOOK_ID SUM(PRICE)
             1   30670848
             2    3801088
             3   15597568
             5    1310720
    Elapsed: 00:00:02.06
    flip@FLOP> SELECT book_id, sum(price)
      2  FROM ( select * from t1
      3         union all
      4         select * from t2
      5       )
      6  GROUP BY book_id;
     
       BOOK_ID SUM(PRICE)
             1   36569088
             2    8388608
             3   23461888
             4    2621440
             5    1310720
     
    Elapsed: 00:00:04.01
    flip@FLOP>
    flip@FLOP> with a1 as
      2       (
      3         select book_id, sum(price) p
      4         from   t1
      5         group by book_id
      6       )
      7      ,a2 as
      8       (
      9         select book_id, sum(price) p
    10         from   t2
    11         group by book_id
    12       )
    13  select nvl(a1.book_id,a2.book_id), nvl(a1.p,0)+nvl(a2.p,0)  p
    14  from  a1 full outer join a2 on (a1.book_id = a2.book_id)
    15  ;
     
    NVL(A1.BOOK_ID,A2.BOOK_ID)          P
                             1   36569088
                             2    8388608
                             3   23461888
                             4    2621440
                             5    1310720
     
    Elapsed: 00:00:04.02

  • How To Create Table View With Same Column name But Different Table?

    Hi All,
    I have the problem to create a tableview with same column name but in different table.
    The Table that i have:-
    Table - PAC051MPROFORMA
    Column - mrn,visitid
    Table - PAC051TPROFORMA
    Column - mrn,visitid
    Table - PAC052MTRANSBILL
    Column - mrn,visitid
    Then i want to create a table view to view that table. This is my SQL
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    That SQL Return this error = ORA-00957: duplicate column name
    Then I modify that SQL to
    CREATE VIEW pacviewproforma (mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    This time this error return = ORA-01730: invalid number of column names specified
    What should i do?
    Thanks...

    Hi,
    SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    ERROR at line 1:
    ORA-00957: duplicate column namePlease give different names to each column.
    Something like this..
    SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
    _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    View created.
    SQL> DESC  pacviewproforma;
    Name                                      Null?    Type
    MPROFORMA_MRN                                      NUMBER
    MPROFORMA_VISITID                                  NUMBER
    TPROFORMA_MRN                                      NUMBER
    TPROFORMA_VISITID                                  NUMBER
    MTRANSBILL_MRN                                     NUMBER
    MTRANSBILL_VISITID                                 NUMBER
    ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
    Twinkle

  • Insert same record on two different tables (no master detail)

    Hi all,
    I'd like to know how to insert 1 record into two different
    tables.
    the first table is corni_dati the second is cornidati_prev
    anytime someone inserts a new record both tables should be
    filled.
    if ((isset($HTTP_POST_VARS["MM_insert"])) &&
    ($HTTP_POST_VARS["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO corni_dati (corni_id,
    disciplina,
    codice_modulo, insegnanti, classi, obiettivi, prerequisiti,
    ud1, ud2,
    ud3, ud4, ud5, ud6, metodologia, collegamenti, verifiche,
    verifiche_note, durata, periodo_inizio, periodo_fine, note,
    indirizzo,
    modnum, modulo_titolo, `data`, compilato, descrizione) VALUES
    (%s, %s,
    %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
    %s, %s, %s,
    %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($HTTP_POST_VARS['corni_id'],
    "int"),
    GetSQLValueString($HTTP_POST_VARS['disciplina'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['codice_modulo'], "text"),
    GetSQLValueString($HTTP_POST_VARS['insegnanti'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['classi'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['obiettivi'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['prerequisiti'], "text"),
    GetSQLValueString($HTTP_POST_VARS['ud1'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud2'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud3'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud4'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud5'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud6'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['metodologia'], "text"),
    GetSQLValueString($HTTP_POST_VARS['collegamenti'], "text"),
    GetSQLValueString($HTTP_POST_VARS['verifiche'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['verifiche_note'], "text"),
    GetSQLValueString($HTTP_POST_VARS['durata'],
    "int"),
    GetSQLValueString($HTTP_POST_VARS['periodo_inizio'], "text"),
    GetSQLValueString($HTTP_POST_VARS['periodo_fine'], "text"),
    GetSQLValueString($HTTP_POST_VARS['note'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['indirizzo'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['modnum'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['modulo_titolo'], "text"),
    GetSQLValueString($HTTP_POST_VARS['data'],
    "date"),
    GetSQLValueString($HTTP_POST_VARS['compilato'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['descrizione'], "text"));
    mysql_select_db($database_itiscorni, $itiscorni);
    $Result1 = mysql_query($insertSQL, $itiscorni) or
    die(mysql_error());
    $insertGoTo = "creacodice_doc.php";
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
    header(sprintf("Location: %s", $insertGoTo));

    If you are doing this then you really should have a look at
    your database
    design. Read up on the first 3 normal forms.
    Pat.
    "darrel" <[email protected]> wrote in message
    news:ee77jg$302$[email protected]..
    >
    >
    > --
    >> Hi all,
    >> I'd like to know how to insert 1 record into two
    different tables.
    >
    > In your SQL query, just use two inserts:
    >
    > INSERT into TABLE1...; INSERT into TABLE2...
    >
    > Darrel
    >

  • Indexes, Clusters, Views and Table Size

    Hi
    Anyone can kindly tell me how to check the size of tables,
    indexs, cluster and views? what are the commands to check the
    size? Thank you so much!
    Xiong

    I believe you just need to query
    user_segments,dba_segments,all_segments, Whichever you have
    access to.
    SELECT segment_name,segment_type,bytes/1024 "KB",extents
    FROM
    user_segments
    where segment_type in ('TABLE','INDEX','CLUSTER');
    I don't think views take up any storage aside from their
    definition in the Data Dictionary. Views are Logical.

  • Passing Parameters For Same Columns In 2 Different Tables

    OBIEE 11g
    I have 2 different dimension tables in my Subject Area.
    Dim1 has following columns: Promotion Code, Promotion Description, Promotion Date
    Fact1 has following columns: a_count, b_count, c_count
    Dim2 has following columns: Promotion Code, Promotion Description, Promotion Date
    Fact2 has following columns: a_count, b_count, c_count, d_count
    Report 1 has following columns: Promotion Code, Promotion Description, Promotion Date, a_count, b_count, c_count (From Dim1 & Fact1)
    Report 2 has following columns: Promotion Code, Promotion Description, Promotion Date, a_count, b_count, c_count, d_count (From Dim2 & Fact2)
    I have tried to pass the parameters Promotion Code, Promotion Description, Promotion Date from Report 1 to Report 2 but this has not worked for me as Report 2 is not receiving the parameters. Is there a way I can do this. Thanks in advance.

    Thanks for your response Jay,
    In Report 1 I have added prompts (Prompts tab) for Promotion Code, Promotion Description and Promotion Date. I have also set the following presentation variables in the prompts:
    PromotionCode,
    PromotionDescription
    PromotionDate
    In Report 2 I then add a filter for each of the same columns and match them to the presentation variables created in Report 1 as follows:
    Promotion Code is equal to / is in @{PromotionCode}
    Promotion Description is equal to / is in @{PromotionDescription}
    Promotion Date is equal to / is in @{PromotionDate}
    My expectation is that the values in the presentation variables will be passed from the Prompts in Report 1 to the filters in Report 2. This is not what is happening. Im not sure what I am doing wrong.

  • Same column name from different table

    i have a sql query as like this : "SELECT * FROM TABLE1,TABLE2". i use oracle. both TABLE1 and TABLE2 have the same column named 'COLUMN1'. while i get rows how i know the value of COLUMN1 from which table (TABLE1 or TABLE2).
    sample code snippet is above. do u help me!
    while (rs.next())
    value1 = rs.getString("COLUMN1");
    // is value1's value from table1 or table2. how do i know this?
    // i try value1 = rs.getString("TABLE1.COLUMN1"); but it doesn't work :(
    ....

    I case you don't know what an alias is, it would look something like this:
    SELECT a.COLUMN1 as FirstColumn1, b.COLUMN1 as SecondColumn1 FROM FirstTable a, SecondTable b
    Notice that in the FROM clause we've appended a short name for each table. You're not limited to one character, but I try to keep it simple. Now we can refer to the tables as a and b.
    Because I did that I have to refer to any ambiguous columns (although it's good practice to refer to ALL columns) using the table name prefix and a period. This tells the driver which "COLUMN1" I want. Then we include as AS clause which allows us to tell the driver what we want that column name to be when it's returned to us. This is specially usefule when I have two columns in two separate tables with the same name (as you have here) or if I'm calculating data (i.e. (a.QTY * b.PRICE) as UnitPrice) that doesn't have a column name, so here I can give it one.
    It's a little weird at first since you use the alias names in the select before you actually define them in the FROM clause, but you'll get use to it.
    Now you retrieve FirstColumn1 and SecondColumn1 from your ResultSet, not Column1.
    HTH.

Maybe you are looking for