Can select from table across db link but cannot create a materialized view

dblink1 is a private db link (it could also be public)
select count(*) from t1@dblink1;
-->
COUNT(*)
5276
create materialized view v1 as
select * from t1@dblink1;
-->
select * from t1@dblink1;
ERROR at line 2:
ORA-00942: table or view does not exist
This only applies to this particular db link. For another db link called "dblink2",
create materialized view v2 as
select * from t2@dblink2;
-->
Materialized view created.
What gives? dblink1 and dblink2 are 2 different databases on 2 different machines.

This is the simplest cause:
dblink2 points to a database that has not a t1 table (as the message says, the table does not exist)
This is the following simple cause:
dblink2 uses a remote user user2, that can not select the t1 table because it exist in another schema, and user2 has not a synonym to the table (post the result of a query over dba_db_links that shows the remote users). Database objects has name and schema. If the objects are in your own schema you dont need to write the schema name, nor if you has a synonym to the object. But if the table t1 is in another schema, and you write t1, it means user2.t1 and fail.
I hope this helps
Regards,
Alfonso

Similar Messages

  • Can I Select from table skipping extents linked with lost datafiles?

    Hi~,
    I need your help to recover my database.
    I'm using oracle 9.2.0.8 at Fedora 3 with no-archive mode.
    and I don't have any backup.
    Last night, I experenced hard disk failure.
    I tried OS-level recovery, but I lost some datafiles of tablespace.
    anyway, I wanted to recover my database without data of lost datafiles.
    so, I issued "alter database datafile offline drop" and
    start oracle instance.
    But, datafiles were not removed from dba_data_files view and
    extents linked with lost datafiles were not removed from dba_extents view!
    Selecting query of some table containing extents linked with lost data files,
    I got "ORA-00376: file xxx cannot be read at this time" message.
    So, my question is that..
    HOW CAN I SELECT FROM THAT TABLE WITHOUT SCANNING EXTENTS LINKED WITH LOST DATA FILES?
    Thanks.

    Hi,
    Without being in archivelog and without backup, one can't do any sort of recovery. That's why backups and archivelog are so so important.
    The offline data file command never does actually drop the datafile. It merely indicates to the control file that now the said tablespace will also be dropped. This won't update any view that the files are not supposed to be used or shown to you anymore.
    This is what documentation says about the recovery of the database in the NoARch mode,
    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/osrecov.htm#i1007937
    You do need a backup in order to get those tables being read. Oracle doesn't have any feature which can offline/skip the missing extents for you and let you read the data without them.
    HTH
    Aman....

  • Can create view, but cannot create table / materialized view: Xpath is null

    Hi all,
    We recently moved some XML documents into the database in an XMLType column and want to query the data. I've been writing some queries and turning them into materialized views. I got to one query, and something really strange is happening. My query returns the expected results, but I am getting an error when I try to create a materialized view out of it. Even stranger, I can create a view out of it, and I can manually insert its data into an existing table, but I cannot create a materialized view out of it and I cannot create a table out of it. Here is a brief summary, please let me know if anyone has suggestions.
    Issuing the following commands fails in SQLDeveloper
    -- Creating a materialized view out of the query fails:
    create materialized view element REFRESH COMPLETE ON DEMAND as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    -- Creating a table out of the query with the following shortcut fails:
    create table element as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    Issuing the following commands in SQLDeveloper works fine:
    -- Creating a view out of the query works:
    create or replace view element as [query];
    -- Creating a blank table from the query and then inserting data works:
    create table element as select * from [query] where 1 = 2;
    insert into element select * from [query];
    Here is a simplified version of the query...
    I have changed the names around, and cut the query down so maybe it will be a little easier to understand. I did confirm that this query is also having the same symptoms described above. Since I changed the names, executing the query returns no results. However creating a materialized view out of the query still fails with the 'Xpath is null' error.
    create materialized view element REFRESH COMPLETE ON DEMAND as
    select
    m.resource_id,
    xml.*
    from metadata_sources m,
    xmltable(
    'for $i in /metadata/app//*[(self::elem1 or self::elem2) and (parent::form or parent::subform)]
    let $formName := if($i/parent::subform) then $i/../../@name else $i/../@name
    let $subformName := if($i/parent::subform) then $i/../@name else ""
    return <data
    appId="{$i/ancestor::app[1]/idField}"
    formName="{$formName}"
    subformName="{$subformName}"
    elemName="{$i/@name}"></data>' passing m.xml_content
    columns
    app_id NUMBER path '@appId',
    form_name VARCHAR2(50 char) path '@formName',
    subform_name VARCHAR2(50 char) path '@subformName',
    elem_name VARCHAR2(50 char) path '@elemName'
    ) xml;
    Edited by: user11949534 on Feb 22, 2013 1:55 PM

    As far as creating a structured index, I was under the impression that I would need to then register an XSD. No, you can use it without an XML schema.
    How about a regular relational view, with an underlying xml index?
    That way you also eliminate the need for an explicit refresh step as you would then be querying real-time data, as if it were relational data.
    For example :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table tmp_xml of xmltype ;
    Table created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="1">ABC</item><item id="2">DEF</item></root>')
      3  ) ;
    1 row created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="3">GHI</item><item id="4">JKL</item></root>')
      3  ) ;
    1 row created.
    SQL> create or replace view tmp_xml_v as
      2  select x.item_id, x.item_val
      3  from tmp_xml
      4     , xmltable(
      5         '/root/item' passing object_value
      6         columns item_id  number      path '@id'
      7               , item_val varchar2(3) path '.'
      8       ) x
      9  ;
    View created.
    SQL> create index tmp_xml_sxi on tmp_xml (object_value)
      2  indextype is xdb.xmlindex
      3  parameters (q'#
      4  XMLTABLE tmp_xml_xtb '/root/item'
      5  COLUMNS item_id  number      path '@id'
      6        , item_val varchar2(3) path '.' #'
      7  ) ;
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user, 'TMP_XML');
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> set lines 200
    SQL> select * from tmp_xml_v ;
       ITEM_ID ITE
             3 GHI
             4 JKL
             1 ABC
             2 DEF
    Execution Plan
    Plan hash value: 4168126828
    | Id  | Operation                    | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                        |       |       |            |          |
    |   2 |   NESTED LOOPS               |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | SYS_C009273            |     2 |    34 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | SYS30366_30367_OID_IDX |     2 |       |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| TMP_XML_XTB            |     2 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("TMP_XML"."SYS_NC_OID$"="SYS_SXI_0"."OID")

  • Insert into table a (select * from table b) - need pk?

    Hi there.
    I'm going to insert into table FINAL (select * from table STAGING) - same structure but in STAGING the ID column has nulls.
    Do I need to provide the ID (primary key) for table FINAL or will it get created based on sequence/trigger?
    If I were doing this in a loop I'd get the next val from the sequence but on a simple insert, I'm curious.
    thanks!

    hmm.. what is ?
    it didn't like it.
    Error(11,4): PLS-00103: Encountered the symbol "[" when expecting one of the following:     begin case declare exit for goto if loop mod null pragma    raise return select update while with <an identifier>    <a double-quoted delimited-identifier> <a bind variable> <<    close current delete fetch lock insert open rollback    savepoint set sql execute commit forall merge    <a single-quoted SQL string> pipe
    9i, sqldeveloper                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Creating the materialized view using the database link

    Hi Guys,
    I am using the Oracle 11g release version.
    Following is my question,
    I had created the Database link to get the data from remote DB table.
    Using that DB link, i can access the required table using SELECT statment.
    When i tried to create the materialized using that DB link.
    I am getting the error SQL Error: ORA-00942: table or view does not exist.
    Can anyone please find the root cause and provide the solution for this?
    TIA,
    Dhivakar.

    Hi Dhivakar,
    try like this
    CREATE DATABASE LINK test
    CONNECT TO scott IDENTIFIED BY tiger
    USING 'orcl';
                         Pls make sure the table name.which ur using to create the materialized view.Thanks
    Venkadesh

  • Can I simulate SELECT * FROM TABLE WHERE ROW IN (1111,2222) using SQLJ

    I have a fct like
    public void fct(String inStr) {
    String str = "SELECT * FROM TABLE WHERE ROW IN" + inStr;
    // then I xecute the query using JDBC connection
    But I want to do the same thisn using SQLJ like:
    public void fct(String inStr) {
    #sql [nctx] iter = { SELECT * FROM TABLE WHERE ROW IN :inStr}
    When I run the second version and give a parameter like "(1111,2222)" it gives
    ORA-01722: invalid number error.
    Is there a way to give parameters to in clauses of SQLJ statements.
    Thanks in regard.

    This is a SQLJ FAQ. You can find the FAQ at:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html
    Your question is addressed in the following section:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#variablesizevaluelist
    Note that that section has a typo. The lines:
    ? // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),?};
    should read:
    ... // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),...};
    By the way, with the next release SQLJ will support pasting in of dynamic SQL fragments. Then you'll be able to do pretty much what you are trying to accomplish here (albeit with slightly different syntax). Until then you'd have to use the workarounds from the FAQ.

  • How do I do SELECT * FROM TABLE WHERE KEY IN ({list})?

    The title says it all really.
    Is there a reasonable performant way to perform the query
    SELECT * FROM TABLE WHERE KEY IN ({list})where {list} is String []?
    I am currently creating a PreparedStatement with a for loop like this   StringBuffer sb = new StringBuffer ("SELECT * FROM TABLE WHERE ID IN (");
      for (int ii=0;ii<keys.length;ii++) {
        sb.append (keys [ii]);
        if (ii != keys.length-1) sb.append (",");
      sb.append (")");but this means that the prepared statement is created each time I call my method and so I'm not sure that the optimizer will find it easy to cope with. Is there a construction that I'm missing along the lines of SELECT * FROM TABLE WHERE KEY = ? where I can create the PreparedStatement once and just call setObject or something on it when the values in {list} change?

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • Special Grant to use "Select * from Table(cast..."??

    Hi,
    I've recently created the types and function to use the Table(Cast(funtion) as type)). It works fine, and gives me the correct result. I've granted execute on the types and on the function to a role that is enabled for a user, but when the user tries to use the "select * from table(cast(function) as type))", he gets a "ORA-01031: Insufficient Privileges" error message. Is there any other grant that must be given to the role, so that the user can execute the select?
    Thanks in advance!
    Daniel

    Hi Kamal,
    I'm not sure what anonymous PL/SQL block means. When I (or the user) try to run the select, I enter all the information, i.e., the owners for the type and function: "select * from table(cast(a.my_function(my_argument) as a.my_type))". I'm trying to use SQLPlus at this time, and I have Oracle 8i.
    I didn't to explicitly grant execute to the user because that would go against some rules I have to follow... I'll se if I give it a try though!
    Thanks!

  • Select * from table as of Scn fails in powercenter

    Hi all, I have written the below query in SQL override of a Powercenter mapping. This fails with 'FROM keyword not found where expected' error. Can you please suggest how else I can fetch last committed data from my source?Select * from table AS OF SCN <Scn no>

    Hi All, I have multiple flat files which i need to load in a single table.I did that using indirect option at session level.But need to dig out on how to populate substring of header in name column in target table. i have two columns Id and Name. in all input file I have only one column 'id' with header like H|ABCD|Date. I need to populate target like below example. File 1                                    File2     H|ABCD|Date.                      H|EFGH|Date.1                                            42                                            5  3                                            6 Target tale: Id    Name1     ABCD2     ABCD3     ABCD4     EFGH5     EFGH6     EFGH can anyone help on what should be the logic to get this data in a table in informatica.

  • Select * from table where rownum 5; no rows returned? why is it so?

    select from table where rownum > 5;*
    no rows returned. why is it so?
    can anyone explain me?

    Hi,
    rownum is pseudo column, and it is based on the sort order.
    For ex, if you want to get the first 5 employees who get the least salary, you use,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal )
        where rownum<=5
    ENAME      SAL                   
    SMITH      800                   
    ALLEN1     890                   
    JAMES      951                   
    TURNER     998                   
    ADAMS      1100Suppose, if you want to use highest salary, you change the order by and not the rownum. So, it becomes,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal desc)
        where rownum<=5
    ENAME      SAL                   
    KING1      5000                  
    FORD       3000                  
    SCOTT      3000                  
    JONES      2975                  
    BLAKE      2850 So, its not the rownum you would want to change, but the order by.
    -Arun

  • Is select from view faster then select from table..???

    Hello Gurus,
    I want to query some data from two tables, both of table have many columns (attributes) and many rows...
    I use several where clauses to retrieve data from those tables..
    witch one is faster, I create a view or I just "select" from those tables???
    Regards.
    Nia...

    riedelme wrote:
    3360 wrote:
    riedelme wrote:
    Selecting through a view almost never helps performance and frequently hurts.Views do not affect performance.
    Views are simply queries and like queries there are fast and slow ones.I disagree.
    First of all, to use a view you are executing a query to get a result set, then accessing the data from that result set - a built-in extra step to perform to get data.First of all that entire explanation of how views work is not correct. The optimizer will rewrite the query to make the view go away if possible.
    SQL> create or replace view v as select * from dual;
    View created.
    SQL> explain plan for select * from dual where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.
    SQL> explain plan for select * from v where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.Exactly the same.
    >
    Second, when accessing the data from the view the result sets don't have indexes for fast lookups and efficient joins on later steps.This is also known as just making stuff up and is not how the database works. care to share any references at all for any of this?
    >
    Third, the systems I've seen that use views extensively - I am looking at one now - tend to perform joins on views using the same tables with the same data over and over. This is a design issue and not specifically a problem with views but they lend themselves to this misuse much too easilyCorrect as I said a view is just a query, and just like queries there are good fast views and bad slow views
    >
    I'll concede that the problem is not specifically with views themselves but as I just said they lend themselves to misuse. Tuning views of views and views joined to views is difficultYes, queries can be misused as can almost all SQL functions and functionality.
    As I said - Views are simply queries and like queries there are fast and slow ones.
    Nothing that you have posted that is accurate changes that.

  • Html form for select * from table a

    Hi all,
    I m looking for report on header/footer part from one apex pages
    which will display context from table a, like sql statement
    select * from table a, written in html.
    Is any examples in java script/html select from tables
    (and same insert into table A (...) select * from table b)
    thanks,
    Gordan

    Hello Gordan,
    Do you want to show the whole report or just some data of it?
    If it's for ex just the name and address you could create two items and have a process or computation to fill it with your select statement.
    If it's the whole report, just create the report and put it in for ex. Region 1. In your page template you can specify that Region 1 needs to come into the footer.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://apex-evangelists.com/
    -- http://apexblogs.info/

  • Xmlgen.getxml("select * from table") returns null pointer exception

    I am running oracle 8i on solaris server and clinet on windows
    NT and i am this select statement
    select xmlgen.getxml("select * from table") from dual ,its
    returning null pointer exception,i have tried it through
    jdbc,even then its returning xml as
    <?xml version = '1.0'?>
    <ERROR>java.lang.NullPointerException</ERROR>
    can any body tell me the error.Help will be really appreciated.I
    need an urgent response,if some one can guide me please.
    My email is [email protected],if you can give me a quick
    response on this email,your effot will be appreciated.
    thanks
    Masood

    What is actually throwing the NullPointerException? rs.getMetaData() or table.setModel()?

  • Select from table containing clob

    If i try to select from table containing clob column in SQL PLus it gives error.
    Tab1 contains 3 clob columns and 1 blob column
    select * from tab 1;
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    The same statement works in SQL Developer and I am able to see the result.
    Actually i am writing the queries and they will be used by Java developers in their JSP page.
    So what happens here? Can Java use these select statements or will it throw error like SQL Plus?

    BLOB column content can't be displayed in SQL*Plus:
    SQL> create table t_blob (b blob);
    Table created.
    SQL> edit
    Wrote file afiedt.buf
      1* insert into t_blob values('01')
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t_blob;
    SP2-0678: Column or attribute type can not be displayed by SQL*PlusBlob and clob columns content can be processed using DBMS_LOB
    package procedures and functions or using client's language (like Java)
    methods. See JDBC specification.
    Rgds.

  • Select * from table not working with Oracle OBDC driver

    Hello,
    In our web development we have been using the MS ODBC for Oracle
    driver to connect to our Oracle db. We decided to try the
    Oracle ODBC driver because it supports the commandTimeout
    property in ASP which the MS driver does not. The problem I'm
    running into now is that all of our select * from table
    statements appear not to be working. The Oracle ODBC driver
    version we are using is ver 8.00.05.00. Is there something that
    I'm not doing properly? If I take the same select * from table
    statement and name the columns, I dont get any error. Otherwise
    I'm getting a Subscript out of range error. It seems strange to
    me that this driver would not support a select * from table
    statement (which I''m told is the case by another developer
    here).
    Is there something I'm missing?
    Thanks,
    Pete

    I'm positive I have a connection. Otherwise I wouldn't get a
    response when I name the columns instead of using *.
    There must be something else that I'm missing or doing wrong.
    I've actually been looking into alternative ODBC drivers to see
    if I have the same problems but none that I have found support
    commandTimeout.
    Any other ideas?

Maybe you are looking for

  • Can no longer print playlists

    Suddenly, I can no longer print playlists for CD jewelcase inserts. I've been printing these with no problem for months and yesterday for the first time, when I select 'print' from the file menuj I get a message saying, " printing of jobs for this pr

  • Lack of support for Pages

    Stupid, Stupid, Stupid. I upgraded Pages on an iPhone 4 running iOS 7 and then foolishly opened one of my documents that was stored in iCloud. All seemed to be working fine until I tried to open the same document using Pages on my 1st Generation iPad

  • In need of desperate help 14yr old daughter's iPod is  a mess.

    When I plug it into the computer it is not showing up, although it makes the sound that it's connected. It just keeps saying "Do not disconnect" and is burning hot. I've tried to reset it and restore it. Now there are no songs on it. When I press sel

  • How to add PDF on itunes 12.0.1? VERY URGENT!!!

    Can someone please explain to me, where I can find iBooks on the new iTunes 12.0.1 (Yosemite)? Or at least to tell me how to put PDF file in iTunes so I can transfer it on my iphone and ipad. IT IS VERRY URGENT!!! Thank you!

  • Help! Unable to Start - weblogic.policy - (Linux) and WLS 5.1