Create Index on another schema table stored in my table
Hi,
I want to create index on a table column which is in another schema from my schema and the index to be stored in my schema.
ex: current user 'hr'
sql>create index idx1 on scott.emp(eno);
Does the above query works??
thanks,
Sri
Why cant you give a try?
Are you getting any error message?
See below..
SQL> show user
USER is "SCOTT"
SQL> grant select on emp to hr;
Grant succeeded.
SQL> conn
Enter user-name: hr@***
Enter password:
Connected.
SQL> show user
USER is "HR"
SQL> create index ndx on scott.emp(sal);
create index ndx on scott.emp(sal)
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> conn
Enter user-name: system@*******
Enter password:
Connected.
SQL> create index ndx on scott.emp(sal);
Index created.
SQL> drop index ndx;
Index dropped.
SQL> grant create any index to hr;
Grant succeeded.
SQL> conn
Enter user-name: hr@*******
Enter password:
Connected.
SQL> create index ndx on scott.emp(sal);
Index created.Edited by: jeneesh on Oct 8, 2012 3:53 PM
Similar Messages
-
Adding named constraints from another schema using stored procedures
I need some help. I am trying to create a constraint like Primary key on a table in schema say 'a' from schema 'b'. in Oracle 10g. Schema b has all permissions of create, alter table, create index and other permissions required.
I can create this constraint from schema b using SQL command 'alter table add constraint...' but not from inside a procedure. I am using 'Execute Immediate' statement to alter table to add constraint. While trying from a procdure, it throws the error as 'insufficeint previleges'.
Kindly advise.it is due to roles.
if schema b has for example role DBA it is not sufficient. You should
GRANT ALTER ANY TABLE TO B;maybe also CREATE ANY INDEX. not sure...
regards
Laurent -
How to create index on a xmltype column stored as CLOB
actually i have two problems.
i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
BEGIN
DBMS_XMLSCHEMA.registerSchema(
schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
,local => TRUE
,genBean => false
,genTypes => TRUE
,genTables => false
,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
END;
then i run this:
create table pf_table_a(
id VARCHAR2(100) primary key,
xsd VARCHAR2(3000),
xml_document XMLType
) XMLTYPE COLUMN xml_document
STORE AS CLOB
XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
ELEMENT "order";
and got this error:
SQL> @d:\usr\dev\perftest\create_tables.sql
Table created.
create table pf_table_a(
ERROR at line 1:
ORA-00955: name is already used by an existing object
anyway the table was created. so i went on to create indexes.
SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
derNo'));
create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
ERROR at line 1:
ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
jack.actually i have two problems.
i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
BEGIN
DBMS_XMLSCHEMA.registerSchema(
schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
,local => TRUE
,genBean => false
,genTypes => TRUE
,genTables => false
,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
END;
then i run this:
create table pf_table_a(
id VARCHAR2(100) primary key,
xsd VARCHAR2(3000),
xml_document XMLType
) XMLTYPE COLUMN xml_document
STORE AS CLOB
XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
ELEMENT "order";
and got this error:
SQL> @d:\usr\dev\perftest\create_tables.sql
Table created.
create table pf_table_a(
ERROR at line 1:
ORA-00955: name is already used by an existing object
anyway the table was created. so i went on to create indexes.
SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
derNo'));
create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
ERROR at line 1:
ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
jack. -
Dropping/Creating index for an individual partition on a partitioned table.
Hi,
I wanted to know how to create and drop index for a single individual partition on a partitioned table.
Thanks..You are not allowed to create an index on a single partition. All the table, mean all the partitiones must be indexed. You can create local or global indexes on partitioned tables. Local indexes ,imho, are easier maintained. For more info refer to documentation http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5010.htm#i2062403
Also, index partitions are maintained through corresponding table partitions. For example, if a table partition is truncated or is dropped, the corresponding index partition is also truncated or dropped (in case of locally partitioned indexes of course). In case of globally partitioned indexes, you will have to rebuild the index each time you truncate or drop a table partition. -
Create package in another schema (10gR2)
Hi there,
I'm trying to create a package in another schema, but I am getting an error when I do this.
My script is as follow:
i log in as user rwn.
create or replace package mkw.test
as
procedure t;
end mkw.test;
create or replace package body mkw.test
as
procedure t as
begin
..... code
end;
end mkw.test;
I get the error: PLS-00103: Symbool "." aangetroffen terwijl een van de volgende
werd verwacht:
What am I doing wrong?
Thanks in advance.user10674103 wrote:
Hi there,
I'm trying to create a package in another schema, but I am getting an error when I do this.
My script is as follow:
i log in as user rwn.
create or replace package mkw.test
as
procedure t;
end mkw.test;
create or replace package body mkw.test
as
procedure t as
begin
..... code
end;
end mkw.test;
I get the error: PLS-00103: Symbool "." aangetroffen terwijl een van de volgende
werd verwacht:
What am I doing wrong?
Thanks in advance.Assuming you have permission to create packages in the other schema?
Are you running this through SQL*Plus? If so, you really need to have "/" terminators after each object you are creating...
e.g.
create or replace package mkw.test
as
procedure t;
end mkw.test;
create or replace package body mkw.test
as
procedure t as
begin
..... code
end;
end mkw.test;
/ -
Unable to create Indexes on F table
Hi
We are unable to create Indexes on one of our Cube's fact table...I tried creating with Process chain , Batch and also tried with SE11 ...table name ... Indexes ...Activate...
Its showing active object generated but the warning msg Index does not exist in database system MSSQL still exist and not creating indexes...When I activate the indexes its not showing this warning for all other cubes...Please advice
regardsHi Sam,.
The index creation on F table is taken care by the system itself. When you activate the cube, the DIM and F table are created and at the same time, indexes are created.
To create your own indes, though, go to se11...>F Table name-->Indeexes-it will show you system created indexes.
There will be a create sign....click there... and give the name of the index(like 1, 2). It will open up the maintain index page, where you have to mention all the parameter.
Thanbks...
Shambhu -
Tuning report by creating index.
Hi...all,
I try to tuning discoverer reports for getting better performance by creating index on columns that used to join
between tables, but when I set join type to one to one relationship and outer join on detail in Discoverer Admin.,I found that index I created was not used in query (explain plan show full scan table).
Anyone know how to solve this problem?
Thank you,
VilasHi,
According to the documentation you will get this error when:
Cause: The select clause referenced UID, USER, ROWNUM, SYSDATE, CURRENT_TIMESTAMP, MAXVALUE, a sequence number, a bind variable, correlation variable, a set result,a trigger return variable, a parallel table queue column, collection iterator, etc.
Action: Remove the offending expression or disable the REWRITE option on the materialized view.
You will probably find you have one of these expressions in your custom business area/folder.
Rod West -
Where to dowload table script for demo table EMPLOYEE
Hello!
I'm reading the book "Oracle PL/SQL Programming, Fourth Edition"
By Steven Feuerstein.
And I can't find the script for the employee table ..
Where can I get it?
Regards
TobiasCopy this script in notepad and then save in .sql format and then run
rem
rem Header: hr_main.sql 09-jan-01
rem
rem Copyright (c) 2001, Oracle Corporation. All rights reserved.
rem
rem Owner : ahunold
rem
rem NAME
rem hr_main.sql - Main script for HR schema
rem
rem DESCRIPTON
rem HR (Human Resources) is the smallest and most simple one
rem of the Sample Schemas
rem
rem NOTES
rem Run as SYS or SYSTEM
rem
rem MODIFIED (MM/DD/YY)
rem ahunold 08/28/01 - roles
rem ahunold 07/13/01 - NLS Territory
rem ahunold 04/13/01 - parameter 5, notes, spool
rem ahunold 03/29/01 - spool
rem ahunold 03/12/01 - prompts
rem ahunold 03/07/01 - hr_analz.sql
rem ahunold 03/03/01 - HR simplification, REGIONS table
rem ngreenbe 06/01/00 - created
SET ECHO OFF
PROMPT
PROMPT specify password for HR as parameter 1:
DEFINE pass = &1
PROMPT
PROMPT specify default tablespeace for HR as parameter 2:
DEFINE tbs = &2
PROMPT
PROMPT specify temporary tablespace for HR as parameter 3:
DEFINE ttbs = &3
PROMPT
PROMPT specify password for SYS as parameter 4:
DEFINE pass_sys = &4
PROMPT
PROMPT specify log path as parameter 5:
DEFINE log_path = &5
PROMPT
-- The first dot in the spool command below is
-- the SQL*Plus concatenation character
DEFINE spool_file = &log_path.hr_main.log
SPOOL &spool_file
REM =======================================================
REM cleanup section
REM =======================================================
DROP USER hr CASCADE;
REM =======================================================
REM create user
REM three separate commands, so the create user command
REM will succeed regardless of the existence of the
REM DEMO and TEMP tablespaces
REM =======================================================
CREATE USER hr IDENTIFIED BY &pass;
ALTER USER hr DEFAULT TABLESPACE &tbs
QUOTA UNLIMITED ON &tbs;
ALTER USER hr TEMPORARY TABLESPACE &ttbs;
GRANT CONNECT TO hr;
GRANT RESOURCE TO hr;
REM =======================================================
REM grants from sys schema
REM =======================================================
CONNECT sys/&pass_sys AS SYSDBA;
GRANT execute ON sys.dbms_stats TO hr;
REM =======================================================
REM create hr schema objects
REM =======================================================
CONNECT hr/&pass
ALTER SESSION SET NLS_LANGUAGE=American;
ALTER SESSION SET NLS_TERRITORY=America;
-- create tables, sequences and constraint
@?/demo/schema/human_resources/hr_cre
-- populate tables
@?/demo/schema/human_resources/hr_popul
-- create indexes
@?/demo/schema/human_resources/hr_idx
-- create procedural objects
@?/demo/schema/human_resources/hr_code
-- add comments to tables and columns
@?/demo/schema/human_resources/hr_comnt
-- gather schema statistics
@?/demo/schema/human_resources/hr_analz
spool off -
Create user who can update another schema table
Hi,
We have a prod system under which we need to update the application schema by running different update statement and create/execute function,procedure,package body. This is very easy if you use the owner schema. But i need to run those activities from another user due to some restriction. How can i do that??
May u suggested to give update any table privilege..but this would give all the dictionary table access also.
Is there any privilege that would allow any other user to update another schema table without using the schema name infront of the table name??
Plss suggestJohn,
Can we use public synonym for it ? I don't know the security risk for it though :
SQL> connect hr/hr
Connected.
SQL> select * from scott.emp;
select * from scott.emp
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> connect scott/tiger
Connected.
SQL> create public synonym scotemp for scott.emp;
Synonym created.
SQL> connect hr/hr;
Connected.
SQL> select * from scotemp;
select * from scotemp
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> connect scott/tiger
Connected.
SQL> grant select on emp to hr;
Grant succeeded.
SQL> connect hr/hr
Connected.
SQL> select * from scotemp;
14 rows selected.
SQL> show user;
USER is "hr"
SQL> update scotemp set ename='SMITHX' where empno=7369;
update scotemp set ename='SMITHX' where empno=7369
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> connect scott/tiger
Connected.
SQL> grant update on emp to hr;
Grant succeeded.
SQL> connect hr/hr
Connected.
SQL> update scotemp set ename='SMITHX' where empno=7369;
1 row updated.
SQL> rollback;
Rollback complete.
SQL>
Regards
Girish Sharma -
How do I move a table from one schema to another schema?
How do I move a table from one schema to another schema?
Grant access to the table from the source schema to destination schema.
GRANT SELECT ON <TABLE_NAME> TO <DESTINATION SCHEMA>A simple way would be to use CREATE Table with select syntax (in destination schema)
CREATE TABLE <TABLE_NAME> AS SELECT * FROM <SOURCE SCHEMA>.<TABLE_NAME><li>However, you would be in <b><u>trouble when the table has index,constraints and triggers</u></b>.
So you can better of grab the DDL statement of the table(and any additional components) andd then create the table in the destination schema.You can use SQL developer, Toad or Apex's Object browser for this.
After the table is created, Insert the records using SELECT.
INSERT INTO <TABLE_NAME> SELECT * FROM <SOURCE SCHEMA>.<TABLE_NAME>This question is discussed in great detail in this <b>AskTom thread</b> -
How to share data in "User_*" tables with another schema
I would like to share the data in the USER_SEGMENTS table with another schema. If I create a view and grant select on the view, when the other schema queries the view the data is identical to themselves querying the SYS.user_segments table directly.
create view sys_user_segments as select * from sys.user_segments;
grant select on sys_user_segments to A;My guess is that the SYS.user_segments table is a view based on the current user.
Is there a way to share this data without creating a copy of the table?
Oracle: 10g
ThanksHi,
All the data dictionary "tables" whose names start with user_ (or all_ or dba_) are actually views, and what results they bring back depend on what schema you logged in to. I don't think there's any way to allow user A to directly see what's in user B's version of user_segments.
Why do you need this? Can you use the all_ views instead, by giving A some privileges on B's objects?
Failing that, you can replicate the data into a regular table. Inside a AUTHID DEFINER stored procedure, the data dictionary views (such as user_segments) are the versions of the procedure owner, so B can write a stored procedure (let's call it populate_my_segments) that populates a regular table (let's call it my_segements), and then grant EXECUTE privilges on populat_my_segments and SELECT privileges on my_segements to user A. A can then refresh the table and look at it whenever he wants to.
If A only needs to see a little information, e.g. the total number of bytes, from B's user_segments, then B can write a function just to return that information. -
Query in Stored Procedure accessing another schema
Hi - this is going to sound kind of strange and even i can't come up with an explanation. My JDK 1.1.7 applet uses a type 4 JDBC thin driver (i think v 8.04.06) to access an Oracle 7.3.4 database. We also have a link with full grants and synonymns to another Oracle schema in an Oracle 8 database. Has never been a problem - we can access anything we need to through queries or stored procedures from either of these databases.
So, i have a new stored procedure that needs to be called through JDBC that queries a table in the Oracle 8 database. For some reason, whenever i execute this stored procedure from java it hangs on this query and the instance needs to be restarted. If i execute that same stored procedure from SQL Plus, it runs fine.
I tried a little test. I put a straight query in my java code that goes directly to that table (no stored procedure involved). It runs great through java!
is this weird or what? my dbas have checked out all privelages and it seems that i have access to everything i could possibly need.
If anyone has any suggestions i would love to hear them.
thanks for your help...
Lori - [email protected]
nullYou can only access an object in another user's schema if you either:
(a) Specify the 'other' schema name explicitly: SCHEMA.OBJECT
(b) A synonymn has been created to access the object: CREATE SYNONYM OBJECT FOR SCHEMA.OBJECT.
The user requiring the synonym should create it, or the user owning the object can create a PUBLIC synonym, if they have the authority.
To check my hypothesis, try typing 'DESCRIBE procedure_name' from SQL*Plus as both users. -
Cannt execute stored proc of one schema in another schema from java app.
I am posting my problem in this forum as i i though it could be server-independent.
I am working on apache tomcat and spring framework with Oracle db (schema/user A)
We access oracle db from our java application by setting jndi and works fine.We have sqlstatements, stored procs and functions all run fine.
Now we create a role (DBROLE) with all permissions to that original db schema/user(A) . We created another empty schema B and assigned that role(DBROLE) to that user B.
(We grant all kind of permissions on tables/packages of schema A to user role DBROLE and also created synonyms)
Intentions are: to access the schema A though schema B from application and avoiding direct access.
In our spring application, we replaced database-settings with schema B.
Things work fine: When its plain SQL statement is run from Java code but Stored proc wont run and we get
'Wrong num of arguments/data types' error.
Also all stored procs are in packages.To execute stored proc in java code, we use SimpleJdbcCall.
I also checked run stored proc from schema B and its works. Only from web app, it doesnt work.
Please suggest,what should be done to make this working or if there is other alternative.
ThanksInstead of importing a scema in another schema specifiy the schemas in the external-schemaLocation property.
SAXParser saxParser = new SAXParser();
saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", "xmlschema1.xsd, xmlschema2.xsd"); -
How to create index not unique at the time of the CREATE TABLE
Hi,
I am trying to find out how in Oracle create secondary indexes that can accept duplicated into the CREATE TABLE statement, without have to execute a CREATE INDEX separately.
As far I can see the only syntax accepted by Oracle 9i to create more than one index at the time of the table creation is:
CREATE TABLE test_tab (x INTEGER, y INTEGER, z INTEGER PRIMARY KEY(x,y), UNIQUE(z))
But, in my case I need to have the unicity only for the primary key, but not for the second index, that I would like to have not unique.
How to do that inside of the CREATE TABLE statement?
Any help?
Thanks a lot in advance.To create an index automatically (not constraint related) , you will need to have an 'event' trigger on the schema that will (IE: detecting a table create/drop matching ARCHIVE_%) , generate the appropriate SQL required (create index sql) and pass THAT to a DBMS_JOB.
Make sure you have job queue's enabled.
This was the ONLY way that I could re-create a view automatically as new tables were created that matched a criteria IE ARCHIVE_JAN06, ARCHIVE_FEB06 etc.
The application's "archiving" method created and was thus aware of these tables and permitted searching within 'archived' data, but 3rd party reporting applications needed to see a view encompassing all data, regardless of the tables involved. The view automatically created was a 'union_all' of all tables concerned. -
Creating a database link to another schema in the same database
Hello,
I'm trying to create a database link to another schema in the same database. It was created without errors, but when I try to use it I receive "ORA-12154: TNS:could not resolve the connect identifier specified" message...
I'm trying to do it because on my production enviroment the databases are separated, so there I can use database links without problem, but in my development environment it's all in one database separated by schemas...
So I'm trying to simulate the same system to not need to rewrite the query every time I move from development to production environment.
Any ideas?
ThanksHi,
Yes, you can create a database link to your own database. I've done it before for exactly the same reason you want to.
(By the way, I think it's a good reason. What are the alternatives?
Having different versions of code for Development and Production? Absolutely not! Terrible idea!
Using synonyms or substitution variables that are set differently in the different databases? That might be more efficient than a database link, but efficiency probably isn't such a big issue in Development.
[Conditional compilation|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/fundamentals.htm#sthref250]? This might be good; it has all the efficienty of the above options, with more clarity.)
Assuming you do want to stick with a database link, not all errors are caught when you create the link.
Is the Development database in the tnsnames.ora file of the Development server? Do you have other database links, either in the Development server or pointing to it, that work? What is different about the ones that work, and the one that doesn't?
Edited by: Frank Kulash on Oct 14, 2009 1:58 PM
The more I think about this, the more I agree with the earlier respondent: synonymns are a good solution for this.
To that suggestion you replied:
On this way I might use "select * from SCHEMA.table" instead of "select * from table@SCHEMA"... I looking for an option to use the second way...Actually, the suggestion was that you say:
select *
from SCHEMA_table_ptr;where schema_table_ptr is a synonym.
In Development, that synonym is defined as schema.table.
In Production, that synonym is defined as table@SCHEMA
Why are you "looking for an option to use the second way"?
If you think that people reading the code should realize that the query is being done via a database link (at least in Production), then add a comment.
Maybe you are looking for
-
Missing update for a game app after updating ios7 any ideas how to get the update
Went to update a game app this morning, had already hit update when the i os7 update screen popped went through with the ios update but after ipad restarted the game update is completely missing any ideas how to get the update back no luck so far
-
Module pool F4-Help problem for a field in custom Infotype(HR).
Dear Gurus, I have created a custom Infotype and fields are like P9015-NAM01. P9015-NAM02. P9015-NAM03. all are fields for name. I want F4 help for these fields with values same as Family Members-First name given in 21 Infotype . for all 3 fields s
-
I don't want to restore photos from icloud onto my new iphone
Hi there, I had an iPhone 4 and just got a new 5c. I backed up my 4 to icloud as i dont't own a laptop. I bought 20GB of storage and everything seemed to work. When I set up new iPhone i selected 'Restore from iCloud Back up' as I need old contacts o
-
Receive an error when merging files
When I try to merge files each file receives an error that says "cannot open file, remove file from list"
-
Looking To Open A Website In Chrome
How can a website, using script within a Adobe pdf, be opened in chrome? A website in Internet Explorer can be opened using: app.launchURL("http://www.agf.com/", true);