Using the answer from the Oracle SQL Developer and PostgreSQL question, I have connected Oracle SQL Developer (4.1.3.20) to my PostgreSQL (9.1.20) database.
But only a weird subset of the objects in the database appears in the SQL Developer "Connections" browser. Specifically:
The public schema (which is the default PG user data schema) doesn't show up. But if I create another schema (e.g. one named schema1 in the screen shots below), the schema does show up.
Within a visible schema (schema1), tables, views, their columns, and their data are visible. So are triggers. There are headings for indexes and functions, but the functions, trigger functions, and indexes that exist are not visible. There aren't even headings for sequences, domains, catalogs, and extensions. Refreshing the display of the schema evokes 'ERROR: syntax error at or near ""INDEX_NAME"" Position: 99'.
Here it is in screen shots:
This is the database as shown in the PgAdminIII object browser
This is the database as shown in the Oracle object browser - also showing the above-mentioned error message
Another weirdness: I can open a SQL window in the Oracle tool and execute both DML (select, insert, etc) and DDL (create table, create function, etc), even in the (invisible) public schema. I can even query the PG catalogs (information_schema and pg_catalog).
So the question is: How can I make the missing objects (most importantly, the public schema) visible in SQL Developer?
~ Thanks, Ken
With SQLdeveloper 4.2, public schema is back ;o)
Related
I have downloaded pgAdmin, made a server, restored the database. Then I connected datagrip IDE with postresql. But then this error is coming
.
The search path set for the console is postgres.poublic (see top-right corner).
The table film seems to exist in schema dvdrental.public (see the database explorer on the left)
Potential explanations:
the table has a different name (for example "Film")
the schema of the table is not on your search_path
the table was created in a different database
the transaction that created the table never committed
I am migrating this Oracle command to PostgreSQL:
CREATE SYNONYM &user..emp FOR &schema..emp;
Please suggest to me how I can migrate the above command.
PostgreSQL does not support SYNOSYM or ALIAS. Synonym is a non SQL 2003 feature implemented by Microsoft SQL 2005 (I think). While it does provide an interesting abstraction, but due to lack of relational integrity, it can be considered a risk.
That is, you can create a synonym, advertise it to you programmers, the code is written around it, including stored procedures, then one day the backend of this synonym (or link or pointer) is changed/deleted/etc leading to a run time error. I don't even think a prepare would catch that.
It is the same trap as the symbolic links in unix and null pointers in C/C++.
But rather create a DB view and it is already updateable as long as it contains one table select only.
CREATE VIEW schema_name.synonym_name AS SELECT * FROM schema_name.table_name;
You don't need synonyms.
There are two approaches:
using the schema search path:
ALTER DATABASE xyz SET search_path = schema1, schema2, ...;
Put the schema that holds the table on the search_path of the database (or user), then it can be used without schema qualification.
using a view:
CREATE VIEW dest_schema.tab AS SELECT * FROM source_schema.tab;
The first approach is good if you have a lot of synonyms for objects in the same schema.
How to get the name of the schema, tables and primary keys?
How to know his authorizations?
The only information I have is obtained by the command below:
db2 => connect
Database Connection Information
Database server = DB2/AIX64 11.1.3.3
SQL authorization ID = mkrugger
Local database alias = DBRCF
You can use the command line (interactive command line processor), if you want, but if you are starting out then it is easier to use a GUI tool.
Example free GUI, IBM Data Studio, and there are many more (any GUI that works with JDBC should work with Db2 on Linux/Unix/Windows). These are easy to find online and download if you are permitted.
To use the Db2 command-line (clp) which is what you show in your question,
Example command lines:
list tables for all
list tables for user
list tables for schema ...
describe table ...
describe indexes for table ...
Reference for LIST TABLES command
You can also use plain SQL to read the catalog views, which describes the schemas, tables, primary keys as a series of views.
Look in the online free documentation for details of views like SYSCAT.TABLES, SYSCAT.COLUMNS , SYSCAT.INDEXES and hundreds of other views.
Depending on which Db2 product is installed locally, there are a range of other command-line based tools. One in particular is db2look which lets you extract all of the DDL of the database (or a subset of it) into a plain text file if you prefer that.
I am using Orable DB in my application and SQL Developer Query Browser for UI Purpose.
Today I faced a very strage issue, I run a query in the query browser which gives me records successfully. But under the connection -> Table tree hierarchy, no tables are displayed.
From stackoverflow I got a solution from here : SQLDeveloper displays no tables under connections where it says tables
But under "Other Users" tree, it displays large list of schemas. So I am confused which schema is used by me query.
Any suggestion ??
Assuming that you are running a query that involves an unqualified identifier
SELECT *
FROM some_object
and that you haven't done something odd like changing the current_schema of the session, the object is either something that exists in your schema or is a public synonym.
SELECT owner, object_type, object_name
FROM all_objects
WHERE object_name = 'SOME_OBJECT'
will show you all the objects that you have access to with that name.
I have created a table, but is not listed on DataStudio 4101(tables node)
I can insert data by sql commands and drop/create the table, but can not find it on the server Database Node, under tables.
Other tables are displayed, but not the new ones I made.
IF you are using DB2 for i, with "system naming" mode, then your tables may have been created in schema QGPL (the General Purpose Library) by default. Your DB2 session would find them by using its "library list", similar to a path list.