Select from a table from other schema
Hi,
I want to make a select from a table how is into other Schema and into other instance.
form example, if I have _2 schemas (in diferent instances)_:
SCHEMA1 =
*(DESCRIPTION =*
*(ADDRESS =*
*(PROTOCOL = TCP)*
*(HOST = XXX.XXX.XXX.XX1)*
*(PORT = 1560)*
*(CONNECT_DATA =*
*(SERVER = DEDICATED)*
*(SERVICE_NAME = SCHEMA1)*
SCHEMA2 =
*(DESCRIPTION =*
*(ADDRESS =*
*(PROTOCOL = TCP)*
*(HOST = XXX.XXX.XXX.XX2)*
*(PORT = 1560)*
*(CONNECT_DATA =*
*(SERVER = DEDICATED)*
*(SERVICE_NAME = SCHEMA2)*
and into SCHEMA2 there is a table TABLE_A.
If I`m connected into SCHEMA1:
how can I do to make a select from the TABLE_A?
thanks very much.
1) Referring to an entry in the tnsnames.ora file as a "schema" as you have here with schema1 and schema2 is likely to be confusing. You have multiple schemas in the same database-- in this case, you appear to be trying to query tables in a different database. If we try to answer using your TNS aliases "schema1" and "schema2", there is likely to be a great deal of confusion between schemas/ databases/ and TNS aliases. So I will assume that your tnsnames.ora file actually reads
TNS_ALIAS1 =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HOST1)
(PORT = 1560)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB1)
TNS_ALIAS2 =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HOST2)
(PORT = 1560)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB2)
)2) Given the TNS aliases above, assuming that we are talking about the tnsnames.ora file on HOST1, you would need to create a database link from DB1 to DB2. You can either specify a fixed username and password for the database link or you can specify that the connection happens as the current user (which assumes that the passwords are synchronized between the databases).
CREATE DATABASE LINK to_db2
CONNECT TO username_on_db2
IDENTIFIED BY password_on_db2
USING 'TNS_ALIAS2'3) Assuming the database link is in place
SELECT *
FROM schema2.table_name@to_db2Justin
Similar Messages
-
Create a table which has columns from another table in other schema
Hi All
I need to create a table which is table driven i.e., the columns of that table need to be inserted from another table in a different schema...Can any one help me with this??create table newtab (--column spec here--) as
Select --columns here-- from otherschema.tablename;max -
Can a procedure select data from tables on other schemas?
Can a procedure select data from tables on other schemas?
If it is posible, which syntax should I use to identify the tables and schemas on the SELECT query?Yes , it is possible..unless the current user has the right privileges on others' db objects schema.
Now , as regards the syntax....
1) The more descriptive way is to use the format ... <owner_schema>.<obj_name>.
2) If you have declared public synonyms of other schema's objects then you can refer to them as just <obj.name>.... but the <owner_schema>.<obj_name> is not wrong.
3) If the db objects reside on another database you must have declared a db link.... then the syntax is <owner_schema>.<obj_name>@<db_link_name>.
Regards,
Simon -
Can we export DATA from all tables in a schema?
Hi,
I have a question; Can we export all the DATA from all the tables present in the schema to any source (eigther CSV, TXT, DAt, etc..)?
Or
Can I have a PL/SQL procedure to display DATA from all Tables in a schema?
With Best Regards,
- NaveedHi,
This is pretty much what you need.
DECLARE
V_COUNT NUMBER;
v_sql varchar2(1000);
IN_OWNER_NAME VARCHAR2(100) := 'AP' ; -- SCHEMA NAME
TYPE T_COL_NAME is table of varchar2(1000) index by binary_integer;
v_col_tbl t_col_name;
BEGIN
FOR i in
(SELECT object_name
FROM dba_objects
WHERE owner = IN_OWNER_NAME
AND object_type ='TABLE'
and rownum < 2)
LOOP
v_sql := 'SELECT COUNT(*) FROM ' || i.object_name ;
EXECUTE IMMEDIATE v_sql INTO V_COUNT;
if v_count > 0 then
v_sql := 'SELECT * FROM ' || i.object_name ;
select column_name
bulk collect
into v_col_tbl
from DBA_TAB_COLUMNS
WHERE TABLE_NAME = I.OBJECT_NAME
AND OWNER = IN_OWNER_NAME;
-- start selecting the column and exporting using the column names selected.
end if;
if v_col_tbl.count > 0 then
for i in v_col_tbl.first .. v_col_tbl.last
loop
DBMS_OUTPUT.PUT_lINE(v_col_tbl(i));
end loop;
end if;
DBMS_OUTPUT.PUT_lINE( i.object_name || '-' || v_count);
END LOOP;
END;
- Ronel -
Is it safe to purge / delete older records from AUD$ table in SYS schema
Hi,
Can we purge / delete older records from AUD$ table in SYS schema.
Please advice.
Thanks
NaveenPl see MOS Doc 73408.1 (How to Truncate, Delete, or Purge Rows from the Audit Trail Table SYS.AUD$) fro details on how to do so.
HTH
Srini -
Grant access to all object/tables in other schemas to a user
Is there any and simple way to grant access to all object/tables in other schemas (more than one) to a scheme/user?
Thanks.
Tarman.HI.
grant SELECT ANY TABLE,delete any table, insert any table to user; Giving this delete,insert ANY TABLE privilege to a user can be dangerous and the use can mislead it. Its better to create a dynamic script and then grant it.
E.g Suppose you want to give select,inert,delete,update privileges to user A on user B's object.
sql> spool grants.sql
sql> select 'grant select,insert,update,delete on '||owner||'.'||table_name||' to A;' from dba_tables where owner='B';
sql>@grants.sqlHTH
Anand -
Grant select on all table of a schema to role
Hi , is it possible to grant select on all table on a schema to a role?
To grant SELECT on all tables of the current schema to particular role or user:
SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
FROM (
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER = (SELECT USER FROM DUAL)
Then copy and execute the result commands, eg:
GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
GRANT SELECT ON EMP TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE; -
Privilege for truncating a table of other schema
Hi friends
I need to truncate a table of other schema. What privilege the other user has to give to carry out it.
Thanks
Edited by: user12892846 on 01-abr-2010 15:59DROP ANY TABLEWhile technically correct, above is somewhat dangerous because every schema could be impacted; even SYS.
Assume SCHEMA_A owns TABLE_A & procedure below.
CREATE & REPLACE PROCEDURE TRUNCATE_TABLE_A
AS
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE TABLE_A';
END TRUNCATE_TABLE_A;
GRANT EXECUTE ON TRUNCATE_TABLE_A TO SCHEMA_B;
By doing as above SCHEMA_A can control who & which table(s) can be impacted (in is own schema only).
Edited by: sb92075 on Apr 1, 2010 7:06 PM -
Unable to take export from particular tables from the schema.
i created a schema duser data is imported and now i want to take select tables from this schema.
the tables are (partyhdr,partyaddressdtl,partycontactdtl,partydsdtl,partytdsexcludedtl,partycurrencydtl)
D:\>EXP DUSER/LOG@ORCL FILE=20121221PARTY0228PM.DMP TABLES=PARTYHDR,PARTYADDRESS
DTL,PARTYCONTACTDTL,PARTYTDSDTL,PARTYTDSEXCLUDEDTL,PARTYCURRENCYDTL;
Export: Release 10.1.0.2.0 - Production on Fri Dec 21 14:30:21 2012
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to: Oracle Database 10g Release 10.1.0.2.0 - Production
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table PARTYHDR 19387 rows exported
. . exporting table PARTYADDRESSDTL 20747 rows exported
. . exporting table PARTYCONTACTDTL 226 rows exported
. . exporting table PARTYTDSDTL 53 rows exported
. . exporting table PARTYTDSEXCLUDEDTL 2 rows exported
EXP-00011: DUSER.PARTYCURRENCYDTL; does not exist
Export terminated successfully with warnings.
as i check in schema partycurrencydtl table is their AND SHOWING RECORDS ALSO.
SELECT OBJECT_TYPE FROM ALL_OBJECTS WHERE OWNER='DUSER'AND OBJECT_NAME='PARTYCURRENCYDTL';
OBJECT_TYPE
TABLE
i am able understand why this particualr table is not exporting.
Kindly help out.Dear hitqon,
i am facing the below problem in export only,but their is no problem in import.
Tablespace Details
FILE-NAME TABLESPACE_NAME BYTES BLOCKS
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\AXPERT.DBF AXPERT 8589934592 1048576
Version:
WE ARE USING version
Oracle Database 10g Release 10.1.0.2.0 - Production
PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - Production
D:\>EXP CENTRAL/LOG@ORCL FILE=20121217CENTRAL0857AMFROMSERVER237.DMP
Export: Release 10.1.0.2.0 - Production on Mon Dec 17 08:57:47 2012
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to: Oracle Database 10g Release 10.1.0.2.0 - Production
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user CENTRAL
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user CENTRAL
About to export CENTRAL's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
EXP-00056: ORACLE error 24324 encountered
ORA-24324: service handle not initialized
EXP-00056: ORACLE error 24324 encountered
ORA-24324: service handle not initialized
EXP-00000: Export terminated unsuccessfully
Only export will be successfully,when we restarted the oracle services. How to over come this issue with out restarting the oracle services.
Edited by: leen on Dec 28, 2012 12:43 AM -
Insert records from one table to other table
Hi,
I want to insert all the records from table 1 which are not in table 2 into table2
o/p
insert into table2
select * from table1
where a.id!=b.id;
Please let me know is there any way that I can populate the recordsinsert
into table2
select *
from table1
where id not in (
select id
from table2
);SY. -
Error "no database selected" when importing tables from MySQL
I'm trying to import tables from MySQL to OBI repository. However, after selecting the MySQL ODBC and prompting user name and password there's an error:
[nQSError: 16001] ODBC error state: HY000 code: 1046 message: [MySQL][ODBC 5.1 Driver][mysqld-5.0.56sp1-enterprise-glp-nt]No database selected.
Seems like the database is somehow not selected althought I defined it (sakila sample database) in the ODBC connection properties and the ODBC test is successful. Anybody has experiences with MySQL + OBI?
Thanksthe issue was solved by using MySQL odbc 3.51... with that there're no problems whatsoever
-
How can I to rename Table in Other Scheme ?
I some tables area backup, but all are in other scheme , How can I to rename all ?
SQL> rename SYSADM.PS_LOC_CNTRCT_SN to SYSADM.PS_LOC_CNTRCT_SN_999;
rename SYSADM.PS_LOC_CNTRCT_SN to SYSADM.PS_LOC_CNTRCT_SN_999
ORA-01765: specifying table's owner name is not allowed@pmcda Look up prerequisites for RENAME
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9019.htm#i2064929
SQL> show user
USER is "SYSTEM"
SQL> alter table scott.dept rename to department;
Table altered.
SQL> select * from scott.department;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> alter table scott.department rename to dept;Best regards
Maxim -
What privileges for GATHER_TABLE_STATS on table in other schema
Hi,
I'm trying to gather some histogram data for a table in another schema and run into the following error:
begin
DBMS_STATS.GATHER_TABLE_STATS('NGM101','NGG_BASISCOMPONENT', METHOD_OPT => 'FOR COLUMNS SIZE 75 tre_id_o');
end;
ORA-20000: Unable to analyze TABLE "NGM101"."NGG_BASISCOMPONENT", insufficient privileges or does not exist
ORA-06512: at "SYS.DBMS_STATS", line 13172
ORA-06512: at "SYS.DBMS_STATS", line 13202
ORA-06512: at line 2
Statement works fine for the SYSTEM user so I guess I need some privileges to do this. But what privileges do I need? (9i and 10G)
thanks ReneI am getting the same error.
USER sysadm has ANALYZE ANY privilege,infact user has got dba privliege. but still i am getting the same error. what could be the issue here.
SQL> select * from user_role_privs where username='SYSADM' ;
USERNAME GRANTED_ROLE ADM DEF OS_
SYSADM CONNECT NO YES NO
SYSADM DBA NO YES NO
SYSADM PSADMIN NO YES NO
SYSADM RESOURCE NO YES NO
SQL> connect sysadm/sysadm
Connected.
SQL> exec DBMS_STATS.GATHER_TABLE_STATS (ownname=>'sysadm', tabname => 'PS_SJT_PERSON');
BEGIN DBMS_STATS.GATHER_TABLE_STATS (ownname=>'sysadm', tabname => 'PS_SJT_PERSON'); END;
ERROR at line 1:
ORA-20000: Unable to analyze TABLE "SYSADM"."PS_SJT_PERSON", insufficient
privileges or does not exist
ORA-06512: at "SYS.DBMS_STATS", line 13046
ORA-06512: at "SYS.DBMS_STATS", line 13076
ORA-06512: at line 1 -
Grant select on all tables of a schema
I need to grant select on all tables (over 200 tables) of a schema to other users. Are there any SQL syntax to do this?
Thanks!Execute the following script, modify it for your environment:
Script
Accept from_owner char prompt 'Grant from user:'
Accept to_user char prompt 'grant to user:'
set head off;
set lines 300;
set pages 0;
set termout off;
set feedback off;
set head off;
set verify off;
spool d:\temp\grant.sql
select 'grant select on &from_owner..'||
table_name||
' to &to_user;'
from dba_tables
where owner=upper('&&from_owner');
spool off;
set head on;
set pages 24;
set termout on;
set feedback on;
set head on;
@d:\temp\grant.sqlExecution example:
system@DBA> @d:\temp\grants.sql
Grant from user:scott
grant to user:ejemplo
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded. -
Extracting data from Z-table from SAP R/3 to BW
Hi all
I want to extract data from a Z-table from SAP R/3 system to Bw system. Currently I am on BW 3.5. Since it is a Z table I dont have a standard extractor for it & I dont knw how to create it. Can anyone provide me with the step-by-step documentation of how to extract data from a non standard SAP table????Hi
You need to create Generic Datasource on the Z-Table you want to get data from
Go to RSO2 transaction to create generic datasource .
You need to give technical name of datasource under datasource type you want and click on create. Then you can give descrption and Application component under which u want see the datasource,
enter the z table name under view/ table and save.
here you can click on check boxes to make fields hidden or selection fields.
Regards
Ravi
Edited by: Ravi Naalla on Aug 25, 2009 8:24 AM
Maybe you are looking for
-
HT1229 i need to back- up my photos from my MacBook air to my iPad- how do i do this?
HT1229 did not help me- does any one know how to back up the photos on my computer to my iPad?
-
HP Pavillion won't go into sleep mode
I have an HP Pavlillion that's about 3 years old. Recently when the comeputer goes into sleep mode (or when I put it in sleep mode), but the computer keeps going in and out sleep mode. It's like the computer goes into sleep mode then about 10 min. la
-
Field not appearing in Field Catelog (V/60)
Hi Guys, I need to replace an existing table by creating a new Table in the existing Access Sequence with the combination of "Ship to Party/Product Hierarchy". Logistics>Shipping>basic Shipping functions>Output determination>Maintain Condition Tables
-
Installation of IDES on 32bit Windows with MSSQL
Hi I know you heard a lot of these questions, but i did not find a specific solution for my case: My goal is to install an IDES system. For this I need the Solution Manager Key. The Key is generated with the Solution Manager. The Solution Manager can
-
Hi, I have created a Cascading LOV for Employee-> Dept No and unchecked Hierarchical View in u201CCreate Cascading List of Valuesu201D option. Then I created a Webi report and applied u201CDept Nou201D as Prompt with LOV option enabled. When I refres