Table T1 in Schema A, Synonym T1 in Schema B, View V1 in Schema B.

Hi,
There are two schemas Schema A and Schema B
Table-> XML_TABLE is in Schema A.
If I create a view V1 with the following query:
SELECT *
FROM XML_TABLE t
WHERE XMLEXISTS (
'declare namespace nmsp ="name:namespace"; fn:collection("oradb:/PUBLIC/Table2")/ROW[ColumnName=$d/nmsp:Colmn2/nmsp:id]'
PASSING t.textxml AS "d")
My XML Indexes are used and output is fast.
BUT in Schema B also I have a synonym for table XML_TABLE pointing to the table in Schema A.
And I create a similar view v1 in schema B also using the same query as above.
BUT this doesn't use indexes. I can see that in the plan and also query never gets executed.
So IS IT correct to have table in schema A, Synonym in Schema B for this table and View in Schema B for this.
How should I make it work
OR
Should I remove the view to Schema A only?
Thanks..
Edited by: user8941550 on Dec 12, 2012 11:56 PM

user8941550 wrote:
Hi,
There are two schemas Schema A and Schema B
Table-> XML_TABLE is in Schema A.
If I create a view V1 with the following query:
SELECT *
FROM XML_TABLE t
WHERE XMLEXISTS (
'declare namespace nmsp ="name:namespace"; fn:collection("oradb:/PUBLIC/Table2")/ROW[ColumnName=$d/nmsp:Colmn2/nmsp:id]'
PASSING t.textxml AS "d")
My XML Indexes are used and output is fast.
BUT in Schema B also I have a synonym for table XML_TABLE pointing to the table in Schema A.
And I create a similar view v1 in schema B also using the same query as above.
BUT this doesn't use indexes. I can see that in the plan and also query never gets executed.Ok, I was following you to that point, but what do you mean the query never gets executed?
So IS IT correct to have table in schema A, Synonym in Schema B for this table and View in Schema B for this.Well, it's not incorrect. Perhaps more tidy to just have the view defined in schema A along with the table, if it's going to be used in schema A as well, and then have a synonym for schema B to use that view.
How should I make it work
OR
Should I remove the view to Schema A only?Perhaps you could post an example of your table with some example data for people to use, along with the views and statement to set up the synonyms, so it can be reproduced by others to see what's going on. Also, post the explain plans you're referring to.

Similar Messages

  • Renaming View from another schema

    Hi,
    I've 2 schemas  namely  department  ,  hr
    Now department schema is having one table EMP . And a view is created on that table with the name R_EMP
    Schema Name :  department
    Table Name  :  EMP
    View Name   :  R_EMP
    GRANT SELECT ON R_EMP  TO  HR ; 
    In HR schema a synonym has been created on view R_EMP with the name R_EMP .
    CREATE OR REPLACE SYNONYM hr.R_EMP for department.R_EMP
    Schema Name :  hr
    Synonym Name:  R_EMP
    Now I want to rename the view name R_EMP  to V_EMP  from  HR schema only
    So, I tried the folloiwng syntax in HR schema (All the operations should be done from this schema only )
    [code]
    RENAME department.R_EMP to department.V_EMP ;
    Error:
    ORA-01765: specifying table's owner name is not allowed
    [/code]
    How to change the syntax to make the statement work from HR schema .
    Thank You .

    Smile,
    The questions is pretty much answered now. You might want to have a look at this as well.
    How to rename a table in another user's schema
    You can alter the session to set your current schema to the name of the schema where you want to rename the view and then do a direct rename.
    Thanks,
    Ishan

  • Performance Problem: Synonym in Schema Referencing Synonym in Diff Schema

    Does anyone have any experience using a synonym in one schema that references another synonym in another schema? I found that if I do it this way, the performance drops considerably depending upon the SQL. It runs slow and in some cases I get Oracle errors (i.e. Invalid ROWID). If I change my synonym to reference the actual table in the other schema, it don't get the same degradation in performance.
    I'm curious if anyone has experienced the same problem and what options might be available to improve the situation. I lose the "semantic" layer by doing this - having to always reference the physical table instead of the synonym in the other schema.
    Thanks for any input or comments you might have.
    Sabert

    Only 2 schemas. Schema A has a table T1 with a public synonym S1. I am running sql against Schema B, however I have a private synonym S2 in this schema (B) that references synonym S1 in Schema A. Because I am using a synonym to reference another synonym in another schema I'm having performance issues. I tried a test and changed the S2 synonym in schema B to point to the table T1 instead of S1 in schema A and it performed much better. Just want to understand what I'm seeing here. This example might help:
    Schema A:
    "CREATE SYNONYM S1 FOR T1"
    Schema B (I'm running my sql against this schema, but my synonym points to table in schema A):
    "CREATE SYNONYM S2 FOR A.S1"
    "INSERT INTO XXX SELECT * FROM S2"
    I had performance issues with this synonym to synonym, so I changed it to synonym to table:
    "CREATE SYNONYM S2 FOR A.T1"
    Again, with the change in reference from a synonym to the actual table, things seem to work better. Hope this makes sense.
    Thanks for your help.

  • XML Schema Collection (SQL Server 2012): How to create an XML Schema Collection that can be used to Validate a field name (column title) of an existing dbo Table of a Database in SSMS2012?

    Hi all,
    I used the following code to create a new Database (ScottChangDB) and a new Table (marvel) in my SQL Server 2012 Management Studio (SSMS2012) successfully:
    -- ScottChangDB.sql saved in C://Documents/SQL Server XQuery_MacLochlainns Weblog_code
    -- 14 April 2015 09:15 AM
    USE master
    IF EXISTS
    (SELECT 1
    FROM sys.databases
    WHERE name = 'ScottChangDB')
    DROP DATABASE ScottChangDB
    GO
    CREATE DATABASE ScottChangDB
    GO
    USE ScottChangDB
    CREATE TABLE [dbo].[marvel] (
    [avenger_name] [char] (30) NULL, [ID] INT NULL)
    INSERT INTO marvel
    (avenger_name,ID)
    VALUES
    ('Hulk', 1),
    ('Iron Man', 2),
    ('Black Widow', 3),
    ('Thor', 4),
    ('Captain America', 5),
    ('Hawkeye', 6),
    ('Winter Soldier', 7),
    ('Iron Patriot', 8);
    SELECT avenger_name FROM marvel ORDER BY ID For XML PATH('')
    DECLARE @x XML
    SELECT @x=(SELECT avenger_name FROM marvel ORDER BY ID FOR XML PATH('Marvel'))--,ROOT('root'))
    SELECT
    person.value('Marvel[4]', 'varchar(100)') AS NAME
    FROM @x.nodes('.') AS Tbl(person)
    ORDER BY NAME DESC
    --Or if you want the completed element
    SELECT @x.query('/Marvel[4]/avenger_name')
    DROP TABLE [marvel]
    Now I am trying to create my first XML Schema Collection to do the Validation on the Field Name (Column Title) of the "marvel" Table. I have studied Chapter 4 XML SCHEMA COLLECTIONS of the book "Pro SQL Server 2008 XML" written by
    Michael Coles (published by Apress) and some beginning pages of XQuery Language Reference, SQL Server 2012 Books ONline (published by Microsoft). I mimicked  Coles' Listing 04-05 and I wanted to execute the following first-drafted sql in
    my SSMS2012:
    -- Reference [Scott Chang modified Listing04-05.sql of Pro SQL Server 2008 XML by Michael Coles (Apress)]
    -- [shcColes04-05.sql saved in C:\\Documents\XML_SQL_Server2008_code_Coles_Apress]
    -- [executed: 2 April 2015 15:04 PM]
    -- shcXMLschemaTableValidate1.sql in ScottChangDB of SQL Server 2012 Management Studio (SSMS2012)
    -- saved in C:\Documents\XQuery-SQLServer2012
    tried to run: 15 April 2015 ??? AM
    USE ScottChangDB;
    GO
    CREATE XML SCHEMA COLLECTION dbo. ComplexTestSchemaCollection_all
    AS
    N'<?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="marvel">
    <xsd:complexType>
    <xsd:all>
    <xsd:element name="avenger_name" />
    <xsd:element name="ID" />
    </xsd:all>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>';
    GO
    DECLARE @x XML (dbo. ComplexTestSchemaCollection_all);
    SET @x = N'<?xml version="1.0"?>
    <marvel>
    <avenger_name>Thor</name>
    <ID>4</ID>
    </marvel>';
    SELECT @x;
    GO
    DROP XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_all;
    GO
    I feel that drafted sql is very shaky and it needs the SQL Server XML experts to modify to make it work for me. Please kindly help, exam the coding of my shcXMLTableValidate1.sql and modify it to work.
    Thanks in advance,
    Scott Chang

    Hi Scott,
    2) Yes, FOR XML PATH clause converts relational data to XML format with a specific structure for the "marvel" Table. Regarding validate all the avenger_names, please see below
    sample.
    DECLARE @x XML
    SELECT @x=(SELECT ID ,avenger_name FROM marvel FOR XML PATH('Marvel'))
    SELECT @x
    SELECT
    n.value('avenger_name[1]','VARCHAR(99)') avenger_name,
    n.value('ID[1]','INT') ID
    FROM @x.nodes('//Marvel') Tab(n)
    WHERE n.value('ID[1]','INT') = 1 -- specify the ID here
    --FOR XML PATH('Marvel')  --uncommented this line if you want the result as element type
    3)i.check the xml schema content
    --find xml schema collection
    SELECT ss.name,xsc.name collection_name FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
    select * from sys.schemas
    --check the schema content,use the name,collection_name from the above query
    SELECT xml_schema_namespace(N'name',N'collection_name')
    3)ii. View can be viewed as virtual table. Use a view to list the XML schema content.
    CREATE VIEW XSDContentView
    AS
    SELECT ss.name,xsc.name collection_name,cat.content
    FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
    CROSS APPLY(
    SELECT xml_schema_namespace(ss.name,xsc.name) AS content
    ) AS cat
    WHERE xsc.name<>'sys'
    GO
    SELECT * FROM XSDContentView
    By the way, it would be appreciated if you can spread your questions into posts. For any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • List of tables count and Views count in schema wise

    Hi All,
    I want to get all tables count and views count in Schema wise, What is the query for that?
    Thanks in Advance.

    SELECT COUNT(*) FROM sys.tables t join sys.schemas s
    on s.schema_id=t.schema_id
    SELECT COUNT(*) FROM sys.views t join sys.schemas s
    on s.schema_id=t.schema_id
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SAP DBTech JDBC: [259] (at 26): invalid table name:  Could not find table/view RS_POOL_CLUSTER_TABLES in schema SYSTEM: line 1 col 27 (at pos 26)

    Hi Gurus,
    I am trying to load a HANA column table using the import function and get the following error even though the mappings from the file to the table are 1:1.
    I get the following errors:
    Error 1: SAP DBTech JDBC: Result set is positioned before first row.
    Error 2: SAP DBTech JDBC: [259] (at 26): invalid table name:  Could not find table/view RS_POOL_CLUSTER_TABLES in schema SYSTEM: line 1 col 27 (at pos 26)
    With the following stack trace:
    com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [259] (at 26): invalid table name:  Could not find table/view RS_POOL_CLUSTER_TABLES in schema SYSTEM: line 1 col 27 (at pos 26)
      at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:334)
      at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:165)
      at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:100)
      at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1141)
      at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:888)
      at com.sap.db.jdbc.StatementSapDB.sendCommand(StatementSapDB.java:929)
      at com.sap.db.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:978)
      at com.sap.db.jdbc.StatementSapDB.execute(StatementSapDB.java:256)
      at com.sap.db.jdbc.StatementSapDB.executeQuery(StatementSapDB.java:401)
      at com.sap.db.jdbc.trace.Statement.executeQuery(Statement.java:131)
      at com.sap.ndb.studio.bi.dataprovisioning.util.DBUtil.getPoolTables(DBUtil.java:200)
      at com.sap.ndb.studio.bi.dataprovisioning.util.DBUtil.getTablesToHide(DBUtil.java:188)
      at com.sap.ndb.studio.bi.filedataupload.ui.wizards.pages.SelectTableDialog.createDialogArea(SelectTableDialog.java:108)
      at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:775)
      at org.eclipse.jface.window.Window.create(Window.java:432)
      at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1104)
      at com.sap.ndb.studio.bi.filedataupload.ui.wizards.pages.SelectTableDialog.create(SelectTableDialog.java:186)
      at com.sap.ndb.studio.bi.filedataupload.ui.wizards.pages.ImportFileSelectionWizardPage$14.widgetSelected(ImportFileSelectionWizardPage.java:779)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
      at org.eclipse.jface.window.Window.runEventLoop(Window.java:826)
      at org.eclipse.jface.window.Window.open(Window.java:802)
      at org.eclipse.ui.internal.handlers.WizardHandler$Import.executeHandler(WizardHandler.java:152)
      at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:279)
      at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
      at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
      at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
      at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
      at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
      at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
      at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
      at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
      at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
      at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
      at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:420)
      at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
      at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
      at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
      at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
      at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
      at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
      at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
    I'm sure many of you have come across this before. Any help will be much appreciated.
    Thanks in advance

    Hello Akhtar,
    Have you tryed to delete the heador row from your file?
    I received the same error when loading a csv file, but when I delete the heador row it worked.
    Best Regards,
    Juliana Genova

  • Which table/view has the schema details?

    Hi All,
    In which table/view I can view the different schemas present in the database? Should I sign-in as SYS or any user can read from that table?
    Please help...
    Thanks in advance...

    DBA_USERS will tell you the users that have been created in the database. Some or all of those users may have objects in their schemas, which you can see via DBA_OBJECTS.
    You don't need to be a DBA to query those views, but you do need appropriate privileges. Depending on your Oracle version, you'd need either the SELECT_CATALOG_ROLE role, the SELECT ANY DICTIONARY privilege, or a direct privilege grant on the particular views you're interested in.
    Justin

  • Error using views from other schema

    Hello,
    i recently had problems using the execute immediate statement in Object Types.
    The SQL statement tried to select from some views which were owned by an other schema.
    Although we had public synonyms on these views and the same dynamic sql could be used out of a stored procedure the usage in the object type raised a "table or view does not exist exception".
    using the same views in the same schema where the object types belonged to, was ok.
    example:
    schema: scott
    view: my_view
    schema: dave
    sql: "select from scott.my.view ....."
    works well from a stored procedure, but nor if used in an object type
    create the view in schema "dave" an then
    sql: "select from my.view ....."
    works fine.
    So is someone aware of this behaviour?
    Is this a bug or a feature?
    regards
    peter

    Hello Geoff,
    here is the sample code.
    If the table my_table belongs to the same
    schema runningthe code the code runs with
    no exception.
    But if the table belongs to an other schema
    (lets say SCOTT),
    only having global synonyms and the rigths to
    select on it, the code will raise an exception "table or view does not exist"
    even if we use SCOTT.my_table in the
    select.
    create type query_o as object(
    dummy integer,
    static function get_query return
    varchar2;
    create or replace type body query_o as
    static function get_query return varchar2
    as
    query varchar2(4000) :=
    'select ' &#0124; &#0124;
    ' f.amount_month ' &#0124; &#0124;
    'into :r1 ' &#0124; &#0124;
    'from ' &#0124; &#0124;
    ' my_table f ' &#0124; &#0124;
    'where id=:p1 ';
    begin
    return query;
    end;
    end;
    create type consumer_o as object(
    amount_month number,
    member function find(p_id in integer)
    return consumer_o
    create type body consumer_o as
    member function find(p_id in integer)
    return consumer_o
    as
    l_amount number;
    begin
    execute immediate query_o.get_query()
    using out l_amount,
    in p_id;
    return consumer_o( l_amount );
    end;
    end;
    kind regards
    peetr

  • Spatial query on join view in another schema

    Background:
    I have a schema with tables containing four spatial columns per table. I have a second schema that contains join views of the tables in the first schema. The join view consists of the attributes and any other tabular data that is joined via foreign key to non-spatial tables and one of the four geometry columns. I have a third schema that owns no database objects of its own, but has select privilege to the second schema's view objects.
    We are using Oracle 10.2.0.2 on a windows platform.
    This worked in 9i, the problem only presented itself when we migrated to 10g.
    Problem:
    When I run a spatial query on a join view in the second schema(the schema that owns the object), it runs and returns results in about a second. When I run the exact same query in the third schema it routinely takes 20-30 seconds.
    Here is the query that I run in both schemas with varying query times:
    SELECT COUNT(*)
    FROM two.join_view_a A
    WHERE (MDSYS.SDO_FILTER(A.GEOM, SDO_GEOMETRY(2003,8307,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(26.6396,26.5708,43.346,34.4083)),'QUERYTYPE=WINDOW')='TRUE');
    Question:
    Why does this happen?
    What can I do to fix this problem?
    Thanks,
    John

    Have a read of this posting: Oracle spatial view runing slow as different user
    There are details there about the 'optimizer_secure_view_merging' parameter and the effect it can have on cross schema views in 10.2

  • Sdo_filter fail when query against a spatial view in different schema

    We have a table with X,Y coordinates and would like to run spatial query against it. We do not want to change the table structure, so we opt to use a function based index. USER_SDO_GEOM_METADATA is updated and index is built. Then we created a view with spatial column from the table. Everything works fine with the user who owns the table and view.
    When we try to run a spatial query against the view from a different user, it failed with error. However, if we substitute the select from my_view* with the actual SQL statement that created the view, it works. So it looks like Oracle refuse to acknowledge the spatial index if accessed via view. Here is some simplified scripts:
    --- connect as USER1.
    --update meta data
    INSERT INTO USER_SDO_GEOM_METADATA ( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID ) VALUES
    ('LOCATIONS', 'MDSYS.SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL)',
    SDO_DIM_ARRAY( SDO_DIM_ELEMENT('X', 1300000, 1600000, 1), SDO_DIM_ELEMENT('Y', 400000, 700000, 1) ), 2264 );
    --created index
    CREATE INDEX LOCA_XYGEOM_IDX ON LOCATIONS
    ( SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL)
    ) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    --create view
    CREATE VIEW USER1.MY_VIEW AS SELECT ID ,X_COORD,Y_COORD, SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL) SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0;
    -- run spatial query from view, works fine by user1 by failed on user2.
    SELECT SHAPE FROM (
    SELECT * FROM USER1.MY_VIEW
    ) a WHERE sdo_filter (shape, sdo_geometry ('POLYGON ((1447000 540000, 1453000 540000, 1453000 545000, 1447000 545000, 1447000 540000))', 2264), 'querytype=window') = 'TRUE';
    -- run spatial query from table directly, simply replace the view with actual statements that created the view. works fine by user1 AND user2.
    SELECT SHAPE FROM (
    SELECT ID ,X_COORD,Y_COORD, SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL) SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0
    ) a WHERE sdo_filter (shape, sdo_geometry ('POLYGON ((1447000 540000, 1453000 540000, 1453000 545000, 1447000 545000, 1447000 540000))', 2264), 'querytype=window') = 'TRUE';
    When run against the view by user2, the error is:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 1173
    13226. 00000 - "interface not supported without a spatial index"
    *Cause:    The geometry table does not have a spatial index.
    *Action:   Verify that the geometry table referenced in the spatial operator
    has a spatial index on it.
    Note, the SELECT SHAPE FROM (****) A WHERE SDO_FILTER(....) syntax is a third party application, all we have control is the part inside "(select ...)".
    So it appears Oracle is treating view differently. Have attempted fake the view name into USER_SDO_GEOM_METADATA, did not work. Also, granted select on the index table to user2, did not work.
    if we re-created the view in user2 schema, it worked for user2 but not user1, so it's not something we can do for every user.
    Searched the forum, no good match found. A few posts talked about "union all" in view caused the problem but I do not have the union.
    We are only use Oracle 10g Locator, not full spatial edition.
    Any ideas?
    Thanks!
    Edited by: liu.284 on Oct 4, 2011 12:08 PM

    It seems a bug, where a function-based spatial index is not correctly handled in a view query transformation.
    Not sure if the following works for you or not.
    add a new column "shape" (mdsys.sdo_geometry) in table locations, use a trigger and x_coord/y_coord
    to set values for this new column, and just create a normal spatial index on this new column. (drop the
    function-based spatial index). And create a view like:
    CREATE VIEW USER1.MY_VIEW2 AS SELECT ID , X_COORD, Y_COORD, SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0;

  • How to export all the views in one schema?

    Hi,
    I have more than 1000 views in one shcema.
    How to export all the views in one schema?
    Amy

    Hi,
    It's not a very easy question, I have develop a script wich create a script to create view from old database to new database :
    /* &1: Oracle SID Source
    /* &2: Oracle Schema Source
    SET HEAD OFF
    SET VERIFY OFF
    SET PAGESIZE 0
    SET LONG 40000000
    SET LONGCHUNKSIZE 2000
    SET LINESIZE 2000
    SET FEEDBACK OFF
    CREATE TABLE RECREATE_VIEW(VIEW_NAME VARCHAR2(30), TEXT LONG);
    /* Selection du texte de la vue */
    DECLARE
    w_text long;
    w_text_debut long;
    w_text_column long;
    w_view varchar2 (30);
    w_schema varchar2 (8):='&2';
    CURSOR w_cursor IS
    SELECT a.view_name, a.text
    FROM dba_views a
    WHERE a.owner = w_schema;
    CURSOR w_column IS
    SELECT DECODE (ROWNUM,
    1, 'CREATE OR REPLACE FORCE VIEW ' || '&' || '1..'
    || a.table_name || chr(10)
    || '('
    || a.column_name
    || DECODE (ROWNUM, nbcolumns, ')' || chr(10) || 'AS' || chr(10), ',' || chr(10))
    FROM (select column_name,table_name
    FROM dba_tab_columns
    WHERE owner = '&1'
    AND table_name = w_view
    order by column_id ) a,
    (SELECT COUNT (1) nbcolumns
    FROM dba_tab_columns
    WHERE owner = '&1'
    AND table_name = w_view
    GROUP BY owner, table_name) b
    order by rownum;
    BEGIN
    OPEN w_cursor;
    LOOP
    FETCH w_cursor INTO w_view, w_text;
    EXIT WHEN w_cursor%NOTFOUND;
    w_text_debut := NULL;
    w_text_column := NULL;
    OPEN w_column;
    LOOP
    FETCH w_column INTO w_text_column;
    EXIT WHEN w_column%NOTFOUND;
    w_text_debut := w_text_debut || w_text_column || ' ';
    w_text_column := NULL;
    END LOOP;
    CLOSE w_column;
    w_text := w_text_debut||w_text||';';
    insert into RECREATE_VIEW(VIEW_NAME, TEXT) VALUES (w_view, w_text);
    COMMIT;
    w_text := NULL;
    w_view := NULL;
    END LOOP;
    CLOSE w_cursor;
    END;
    SPOOL scripts_views_&1..sql
    PROMPT SPOOL scripts_views_&1..log
    PROMPT
    SELECT TEXT
    FROM RECREATE_VIEW;
    PROMPT
    PROMPT SPOOL OFF
    PROMPT
    SPOOL off
    PROMPT /* Formattage du fichier SQL */
    !sed 's/[ ]*$//' scripts_views_&1..sql > aprilia.tmp
    !rm scripts_views_&1..sql
    !mv aprilia.tmp scripts_views_&1..sql
    DROP TABLE RECREATE_VIEW;
    EXIT
    I hope that help you.
    Nicolas.

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • Creating a DB view in OIM schema

    For one of my requirement I am asked to create a Database view in OIM schema.
    Now since I cannot share the password for OIM schema, one user will also be required to create in DB having read access on DB view.
    What would be impact of this in IDM application?
    Will there be any impact of creating a user and Database OIM Schema? OIM version is 9.1.0.2.
    Thanks,
    MS

    You mean this?
    select products.name, sum(suppliers.quantity)
      from products, suppliers
      where products.name = suppliers.product
      group by products.name-Arun

  • Exporting views from a schema

    Hi Gurus,
    We have a problem while creating a replica of a remote DB in local.
    We were able to export all DB objects except views.
    As they are critical for making the local DB 'complete', we are looking for a solution.
    We have tried the below query for getting the definition for a single view on a schema, but the query is taking too much time, even if run on the server.
    Select dbms_metadata.get_ddl('VIEW','<VIEW NAME>') from dual
    Please suggeest us a solution for the same.
    NOTE: Unfortunately we don't have any advanced tools and we are just relying on the Oracle SQL developer, even for developement.
    Thanks & Regards
    RK Veluvali

    What error are you getting when you run datapump expdp? If all you want it views you could run
    expdp user/password include=views schema=schema_list ...
    Please post the version you are using and the errors.
    Thanks
    Dean

  • How to register a schema use a .xsd file which has lots of includes schema

    Hello, All,
    Does someone have the experience to register a schema use a .xsd file which contains several tags like <xs:include schemaLocation="../dt/somedatatypes.xsd"/>?
    I tried both the OEM and command line dbms_xmlschema.registerSchema(), although the whole file structure already in the repository, seems like Oracle can't automatically search and find the includes and register it. should I register those includes first? the actual error I got is "ORA-31000: Resource '../dt/somedatatypes.xsd' is not an XDB schema document.ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0 ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26 ORA-06512: at line 2" .
    Any suggestion? thanks in advance...

    We do not (currently) support relative references in included XML Schemas.
    In order to use an include or import the target Schema must first be registered with XML DB under some known location. The schemaLocation argument needs to the 'Docuemnt Location Hint', or URL, that was passed to registerSchema when the included schema was registered.
    If you have cyclic dependancies between schemas you can use the force option of registerSchema to register the first Schema. This will then allow registration of the second schema to succeed. Once the second schema has been successfully registed the first schema must be explicitiy recompiled using dbms_xmlschema.compileSchema().

Maybe you are looking for

  • Creator 2 and Ajax4jsf

    I'm new to JSF and Creator. I was trying to put AJAX functionality with Ajax4JSF to a simple JSF page I made with Java Studio Creator 2 (update 1). I did as they instructed in their tutorials. But it didn't work. Can anyone please tell if there is an

  • I can't get rid of Inactive Internet Accounts

    Under System Preferences -> Internet Accounts I have two Inactive accounts that will not go away. I can highlight them and click the ( - ) button at the bottom, and they will go away for about 10 seconds, but then they reappear. A screen shot is here

  • Constructor of nested table subtype

    The following code gives me an error PLS-00355: use of pl/sql table not allowed in this context (I checked in 11.2.0.2.0): DECLARE   TYPE    t_number_tab     IS TABLE OF NUMBER;   SUBTYPE t_number_tab_sub IS t_number_tab;   v_sub t_number_tab_sub; BE

  • Can i change the back Color from the IPhone 5c

    Can i Chang the back Color from the i-Phone 5c .Now i Heven Pink and i want Blue Shoud i go to a Apple störe to do that and how much does it cost!!!

  • How do I make the shell indentify my program?

    Hi, I wrote a simple command line phone book. I'd like it to work so when I type into the shell "phone Jerry Johnshon" I get Jerry's number for example. I wrote the program in Python as a python script that takes the name as an arguement. However rig