I tried to execute the DESCRIBE command via a database link, but this was the return message:
DESCRIBE <table>#<database>;
ERROR:
------------------------------------
ERROR: object <table> does not exist
1 rows selected
A SELECT on this table works well.
Does Oracle permitts DESCRIBE via a database link?
I'm using the Oracle SQL Developer 1.5.1.
Edit:
Is there another option to describe a table?
Thanks in advance!
You could do something with the all_tab_columns table to get some table information.
select column_name, data_type from all_tab_columns where table_name = 'TABLE_NAME';
I think DESCRIBE is a SQL*Plus feature. See here.
The easiest way to get the description of a table on a remote server would be:
CREATE OR REPLACE VIEW TMP_VIEW AS SELECT * FROM TABLE_A#SERVER
/
DESCRIBE TMP_VIEW
/
If you do a select of the metadata from all_tab_columns for that table present on the DBLink, it'll provide the description of the table.
For Ex:
select * from all_tab_Columns#dblink where table_name='ASDF' and owner='XYZ';
You seem to be using PL/SQL Developer.
DESCRIBE is not an SQL command, it's a query tool alias that gets converted into a series of queries to the system tables.
PL/SQL Developer can not describe tables from remote databases, while native SQL*Plus can.
I can't check it right now, but maybe select * from v$tables#remotedb doesn't give similar information?
In PL/SQL Developer, you can right-click on the table name from the tables folder and click on describe...which gives the same result as the describe command in native SQL plus.
Using Oracle SQL Developer I was able to use DESCRIBE to show the definition of a remote table. However, I had to use the notation
describe schema.table#database
Related
I am a novice Oracle User.
I want to move a table records from QA to Test environment. The table already exists in Test. Would it be something like this ?
insert into wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove ;
Any help is greatly appreciated.
Both the tables in both environments have same number of columns with same data types.
You can use database links in Oracle to do this.Create a database link in your test database called myQADBLink which points to your QA DB.
The code would look something like this
CREATE DATABASE LINK myQADBLink CONNECT TO <username> identified by
<password> USING
'<QA DBconnect string>';
SELECT 1 FROM dual#myQADBLink; -- This is to test if your dblink is created properly.
Now you can copy from QA to test by saying
INSERT INTO wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove#myQADBLink;
Yes, it actually exists, right like you put it.
Here is the full syntax guide for this: http://docs.oracle.com/cd/E17952_01/refman-5.1-en/insert-select.html.
Later, when you might place your tables at the different Oracle instances, google 'Orace DBLink' for the good ;)
How do I query the database name in Oracle SQL Developer? I have tried the following and they all fail:
SELECT DB_NAME();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? Even this one fails too:
show tables;
EDIT: I can connect to the database and run queries such as:
select * from table_name_here;
EDIT 2: The database type is Oracle, this is why MySQL queries are failing. I thought it was related to the database client not the database itself. I was wrong. I'll leave the question as is for other as lost as I was.
Once I realized I was running an Oracle database, not MySQL, I found the answer
select * from v$database;
or
select ora_database_name from dual;
Try both. Credit and source goes to: http://www.perlmonks.org/?node_id=520376.
try this:
select * from global_name;
You can use the following command to know just the name of the database without the extra columns shown.
select name from v$database;
If you need any other information about the db then first know which are the columns names available using
describe v$database;
and select the columns that you want to see;
I know this is an old thread but you can also get some useful info from the V$INSTANCE view as well. the V$DATABASE displays info from the control file, the V$INSTANCE view displays state of the current instance.
Edit: Whoops, didn't check your question tags before answering.
Check that you can actually connect to DB (have the driver placed? tested the conn when creating it?).
If so, try runnung those queries with F5
To see database name,
startup;
then type
show parameter db_name;
DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.
is there a way to actually query the database in a such a way to search for a particular value in every table across the whole database ?
Something like a file search in Eclipse, it searches accross the whole worspace and project ?
Sorry about that .. its MS SQL 2005
SQL Workbench/J has a built in tool and command to do that.
It's JDBC based and should also work with SQL Server.
You will need to use the LIKE operator, and search through each field separately. i.e.
SELECT * FROM <table name>
WHERE (<field name1> LIKE '%<search value>%') OR
(<field name2> LIKE '%<search value>%') OR
... etc.
This isn't a quick way though.
I think the best way would be to
1) programatically generate the query and run it
2) use a GUI tool for the SQL server you are using which provides this functionality.
In mysql you can use union operator like
(SELECT * from table A where name = 'abc') UNION (SELECT * from
table B where middlename = 'pqr')
and so on
use full text search for efficency
http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
Well, your best bet is to write a procedure to do this. But to give you some pointers you can use the INFORMATION_SCHEMA.Tables to get a list of all the tables in a given database and INFORMATION_SCHEMA.Columns to get a list of all columns. These tables also give you the datatype of columns. So you will need a few loops on these tables to do the magic.
It should be mentioned most RDBMSs nowadays support these schemas.
In phpmyadmin, go to your database, reach the search tab.
Here you will be able to select all of your tables and search through your entire db in one time.
Is there a way to send an SQL query to HSQLDB (edit : prior to version 2) to know the columns of a certain table ? (Similar to the inspection of the schemas through INFORMATION_SCHEMA in MySQL.)
Right now it seems to me I'm stuck with trying to SELECT column_name FROM table_name and see if I get an SQL error...
HSQLDB supports the INFORMATION_SCHEMA as well:
http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html#dbc_information_schema
You use queries to the special SYSTEM tables. See the answers to [this question].1
I don't know if anyone can help me. In my job, I inherited a completely undocumented database (Oracle 11). So far, I've managed to map most of the tables and determine what's going on where. However, there are a few columns that I haven't been able to decipher.
Is there some way of finding out how is the data in the column built? This is not a manual input. Everything seems to point to the data being the result of an entry in a different column in a completely different table.
It might be an impossible task, but any and all suggestions will be more than welcome.
Thanks!
C
Perhaps the data is being inserted in your mystery columns via a trigger? Try looking in the PL/SQL source table in the dictionary:
SELECT owner, name, type, line
FROM dba_source
WHERE UPPER(text) LIKE '%MYSTERY_COLUMN_NAME%'
AND type = 'TRIGGER'; -- use or omit this as desired.
This will get you pointed in some possible places to look.
Good luck!
You can retrieve the complete DDL for a table using the DBMS_METADATA package.
SELECT dbms_metadata.get_ddl('TABLE', 'YOUR_TABLE_NAME', 'YOUR_USER_NAME')
FROM dual;
If those columns are really computed columns then this should be visible in the DDL for the table.
Alternatively you can use SQL Developer to show the DDL for the table
I am presuming that you already have the sql that is in question.
select table_name from dba_tab_columns
where column_name = 'COLUMN_YOU_WANT_TO_KNOW'
will provide all tables that contain a column name that you are looking for. If you do not have dba privileges you can use all_tab_columns instead (which will show all tables your account would have access to).