run \dt in oracle sqldeveloper for PostgreSQL - postgresql

I configured PostgreSQL for Oracle SQL developer.
I just tried to run the command \dt; from the worksheet and received below error
Error starting at line : 1 in command -
\dt
Error report -
SQL Error: ERROR: syntax error at or near "\"
Position: 1
Could you please advise how to run the commonly used psql commands from worksheet in Oracle SQL developer.
Edit1:
Are there any alternative equivalent for such psql command for oracle sql developer please. Thanks.

Doesn't SQL Developer offer a GUI view that provides the same info as \dt does? That is its job, afterall, and the point of using a GUI.
You can start psql with the -E option, then it will show you the SQL it executes to get the data behind the various backslash commands. You can then capture and run those queries in something else, like (presumably, I haven't tried it) SQL Developer.

You cannot do that.
psql commands are only available in psql.
Consider using psql, it is superior.

Related

SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;reorg ;JOIN <joined_table>

when running this query on db2 on DBeaver :
reorg table departments
i got this error (just on external channel):
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;reorg ;JOIN <joined_table>, DRIVER=4.19.49
what does this query mean?
how can I fix the error?
appricicate any help.
Try call sysproc.admin_cmd('reorg table db2inst1.departments')
as you are using DBeaver which is a jdbc application.
If you do not qualify the table name (for example, with db2inst1) then Db2 will assume that the qualifier (schema name) is the same as the userid name you used when connecting to the database.
DBeaver runs SQL statements, but it cannot directly run commands of Db2 - instead, any jdbc app can run Db2-commands indirectly via a stored-procedure that you CALL. The CALL is an SQL statement.
The reorg table is a command, it is not an SQL statement, so it needs to be run via the admin_cmd stored-procedure, or it can be run from the operating system command line (or db2 clp) after connecting.
So if you have db2cmd.exe on MS-Windows, or bash on linux/unix, you can connect to the database, and run commands via the db2 command.

ERM from PostgreSQL via psql (SQL Shell)

I need to understand the relations between tables in a PostgreSQL database. I will not have the ability to download pgAdmin4 like I am used to working in. So after looking around I found pg_dump.exe built into PostgreSQL. I thought I could just do something like this in the SQL Shell (psql) to get a dump of the database and then have the ability to upload it into another system:
database=# pg_dump database > path/to/save/file.sql;
Based on the docs >> https://www.postgresql.org/docs/9.3/app-pgdump.html
But when I run that I get an error:
ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump database > path/to/save/file.sql;
^
I saw on this stack overflow question was similar to my issue with the pg_dump error. In the solutions, Adrian says that pg_dump does not work within psql. When I run the code that Adrian suggested, I also get an error.
Any thoughts on how I can use psql to get the information that I need of this database?
Note: I am accessing a Linux VM on a Windows machine.

Describe command in DB2 data studio

My new Project is using DB2 9.7 version, and the GUI used is Data Studio. But the basic Describe command is not recognized. The query I am using is:
DESCRIBE table Select * from risk.risk_basic
and the error am getting is :
unexpected token "DESCRIBE Select *" was found following
"BEGIN-OF-STATEMENT"
As #data_henrik wrote it is a command and cannot be executed through a JDBC connection. YOu could switch the editor connection to a DB2 Server Command Line Processor though ...
This is described in the following answer of mine
https://dba.stackexchange.com/questions/161117/reorg-command-does-not-work-in-ibm-data-studio-but-same-works-in-command-line-pr

Unable to create new Postgres database

I'm unable to create a new database for the first time after installing postgres.app on my macbook pro
Anyone here can point me to the origin of the problem ?
createdb is not a SQL statement, it's program for the command line (like psql or grep).
Inside psql you need to use the SQL statement CREATE DATABASE:
http://www.postgresql.org/docs/current/static/sql-createdatabase.html
And don't forget to terminate every SQL statement with a ; (if you had done that with createdb you would have gotten an error message immediately).

Using squirrel sql with postgresql: backslash syntax error?

I am trying to run basic postgresql commands which start with a backslash within Squirrel SQL sql client. For example, I'd like to be able to type
\dt
to mean "SHOW TABLES" instead of
"SELECT * FROM information_schema.tables WHERE table_schema = 'public';"
This works from the psql command line. However, when I try to run "\dt" within Squirrel I get a syntax error message:
Error: ERROR: syntax error at or near "\"
Position: 1
SQLState: 42601
ErrorCode: 0
I assume there's some kind of SQL syntax checking going on here on the part of Squirrel? Does any one know a way to make PostgreSQL commands which start with a backslash work in Squirrel SQL? I have the Postgres plugin installed...
Thanks,
The backslash commands are part of the psql client, not the PostgreSQL backend server. psql translates them into batches of SQL, which you can see by running psql with the -E flag, and uses the results to produce the displayed output.
This means you can't use these commands from other clients.
Alongside the inability to use pg_dump from within a PostgreSQL protocol session, or get equivalent functionality from the backend server, this is a bit of an FAQ.
At this point the only real option is to use a client that understands the information_schema or PostgreSQL's catalogs (pg_catalog) and can produce the display you want its self. A popular choice is PgAdmin-III, though I stick with psql myself.