Cannot select Oracle table from other Server with schema name prefix - oracle

Few days ago there was network problems. Also one of the database harddisk partition storage ran out of space but it has been fixed now.
Additional note: one of the DBA compressed the archive log to spare some space during the problem happened.
One of the outcome was that now I CANNOT select one table from other Oracle database on the other server if using schema name prefix.
For example if I run query from one of the schema/user in database1 from Toad or sqlplus:
select * from office.room#database2
The query runs forever and never stops.
Usually it's not a problem. The other tables are fine; I can select them using office.*#database2 query.
The other odd thing is that if I use SYNONYM, I CAN select that table. Let's say that table has synonym 'room' on db2 database, this query is OK:
select * from room#database2
The table itself on database2 is OK, meaning that if I login to schema "office" on database database2, I can select the table data.
I still can not find out what causes this problem.
New founding, I can select the table with no hang up if I add WHERE filter or I select the columns, for example :
select * from office.room#database2 where roomnumber='A';
or
select roomname, rumnumber from office.room#database2;
But the select * from office.room#database2 still hang up.

Related

system.mutations is not responding after I ran an ALTER sql on a table A. Table A is also stuck. I just want to drop Table A

I ran an ALTER sql on Table A. Then table A is stuck, system.mutations is not responding. I also wait 3 hours. I tried below actions,
restart Clickhouse service, reboot this Clickhouse server machine. reboot my client computer.
checked log, and found this, "Current max source part size for mutation is 0 but part size 1513. Will not mutate part all_24_24_0. "
The sql I used is like "alter table A update columnA=columnA/(select sum()....) where ...."
No other data is inserting. No recoreds in system.merges or system.replication_queue.
Table A has around 1000 records
I just want to drop this table A, then I can recreate it with the history records, but table A is not responding. Also system.mutations.

Would a Temporary table be dropped automatically in Oracle?

Forgive me to ask a silly question.
Would a temporary table be dropped automatically in Oracle (12c)?
Yesterday I have executed the following DDL to create a temporary table:
Create global temporary table my_1st_t_table on commit preserve rows as
select
*
from
other_table
where
selected_col = 'T';
After that I have executed following statements:
commit;
select count(*) from my_1st_t_table;
Yesterday, the last select statement returned 2000 rows.
After that I disconnected my VPN and also switched off my client laptop.
Today I rerun the last select statement after restarted my computer and reconnected to the VPN.
It returned 0 rows. So this means the table was still there but just all rows being deleted after my session.
However, may I ask when will my temporary table be dropped?
Thanks in advance!
A temporary table in Oracle is much different than a temp table in other database platforms such as MS SQL Server, and the "temporary" nomenclature invariably leads to confusion.
In Oracle, a temporary table just like other tables, and does not get "dropped". However, the rows in the table only exist within the context of the session that inserted the rows. Once the session is terminated, assuming the session did not delete the rows, Oracle will delete the rows in the table for that session.
So bottom line, the data is temporary, the table structure is permanent, until the table is dropped.

Trigger to execute the same query on linked database

I have two tables table1 in local system and table2 on another system. I created database link to table2 in local sytem I.e table2#anothersystem
I have two columns in both tables ID (number) & NAME (varchar). I want to execute any query on table1 such that after it's execution in table1 it will also be identically executed in table2.
In short I want to keep table1=table2. can anybody suggest trigger for it in Oracle 11g
As #justin-cave already mentioned, using triggers is definitely not the way to go. I'd opt for a materialized view (the cheap option). Check Oracle materialized view question for a starting point. When you have the appropriate license you could create a logical or physical standby database, or other Oracle-provided data replication options.

oracle 11g dispaly user created tables

Hi I m new to oracle using 11g exprs edition and familiar with mysql. We can use the below code to display all databases in mysql
show databases;
What is the corresponding command in Oracle. Or how can i display all databases. Also We have
use mydatabase;
to chanage database in mysql. How can i change database in oracle. I tried to display all owners and their tables using the following command
select table_name, owner from all_tables;
It working fine. But when I tried to display tables I have created, by adding a where cluase
select table_name, owner from all_tables where owner='root';
it shows no rows were selected. Why this happens? Also I am facing the same problem with most of the queries when using the where clause. Without where clause it works fine. but when using it, the result is no rows selected for example
select * from all_tab_comments where owner='root';
select constraint_name, constraint_type from user_constraints where table_name='location';
Is there anything special in oracle for where clause or the problem with my query.
Your username is very unlikely to be root; it could however be ROOT, in which case you could do:
select table_name, owner from all_tables where owner='ROOT';
The owner name is case-sensitive, and all objects including users and table names are upper-case by default (unless they're created with double-quotes, which is a bad idea). If you're connected as that user, to see only your own tables you can also do:
select table_name from user_tables;
And there is the dba_tables view which also shows you tables you don't have permissions on, but you can only see that with elevated privileges.
Oracle doesn't have 'databases' in the same sense as other products. You probably means schemas, as the logical grouping of objects. And schemas and users are essentially synonymous.
To get a list of all schemas you can query dba_users (if you have the right privileges), or to get a list of schemas that have objects - as you may have users who only use objects in other schemas - you can do:
select distinct owner from dba_objects;
... or all_objects to again only see things you have permissions for. To see what kind of objects:
select owner, object_type, count(*) from dba_objects group by owner, object_type;
The documentation explains the static data dictionary views which hold all of this information. You won't be able to see all of them though, unless you're connected as a privileged user.
There will be a lot of differences between the two products; you might be better off trying to find a tutorial that works through them rather than using trial and error and trying to understand what's gone wrong at each step. Or at least familiarise yourself with the Oracle documentation so you can research issues.
First, there is going to be a terminology difference when you change platforms. What MySQL calls a "database" is most similar to what Oracle calls a "schema". If you are using Oracle XE, you can only have one database (using Oracle terminology) on the machine. You can have many schemas within that database.
The owner in all_tables is the name of the schema that owns the table. Assuming that you created an Oracle user root (which seems like an odd choice for a database user) and assuming that you did not create a case-sensitive user name in all lower case (which would create a ton of issues down the line), the owner will always be upper-case.
SELECT owner, table_name
FROM all_tables
WHERE owner = 'ROOT'
In Oracle, you do not generally change from one schema to another. You either fully qualify the table name
SELECT *
FROM schema_name.table_name
or you create synonyms (public or private) for objects that you want to reference
CREATE SYNONYM synonym_name
FOR schema_name.table_name;
SELECT *
FROM synonym_name
If you really want to, however, you can change your current schema for name resolution purposes
ALTER SESSION SET current_schema = <<schema name>>
use the view : tabs
select * from tabs;

Create table as select using dblink doesn't move all the rows

We are moving from an amazon ec2 database to an amazon rds database. Most of the tables are small and could be moved using sql developer copy commands but a couple are bigger (3M+ records). In order to speed those up, I created database links between the two system. Those work fine. I then ran the following:
create table schema.tablename as select * from schema.tablename#ec2db;
ec2db is the old database. The table there contains 3,503,064 records. However the NEW databse table only contains 3,454,685 records. No errors were generated during the create table statement. This is repeatable (ie: I drop the table and run it again, and it loads the same number of records.)
Any ideas why this would happen? Why would the contents of a table when I do a select (*) not be the same as the contents of the same table (fully specified) when I do a create table?

Resources