Using USE in ColdFusion with Postgres - postgresql

Postgres doesn't have the USE directive, unlike SQL Server or MySQL. There is the \c <database> command, but that only works in the psql REPL. Is there an alternative to USE that can be used with cfquery in Postgres? We would be using this with CF 11.

Related

Switch between databases in PGAdmin4

How we can connect to specific database by using sql commands in pgadmin4 postgresql
in psql command line,its already working \c database name,same thing we want to connect to specific database in pgadmin4 postgresql
The pgadmin4 SQL window executes only SQL commands, which are bound to a specific database. \c is an internal psql command.
You need to open separate SQL windows per database in pgadmin4.

Creating a database dump doesn't seem to be working

I have PostgresQL 9.6.2 installed, and I'm trying to make a backup of one of my databases (my_database) using pg_dump command. It doesn't seem to be working as I see no output file.
I'm using a Mac and from my terminal (and in my project directory) I use:
psql postgres postgres
pg_dump my_database > my_database.bak
being postgres my database default user and password.
I've already tried using sudo psql postgres postgres with the same results.
I imagine that I'm experiencing some kind of lack of permissions but cannot understand it.
So, how to have the right permissions to do this?
Postgres comes with a bunch of stuff, including command-line tools. That includes the standard client, psql, and also the command pg_dump. That needs to be invoked from a shell command line.
If you type it into a psql command line, you'll get a syntax error once you terminate the line (with a ';') -- it's not valid sql, nor a valid command to psql.
Hope that helps!

How to check table value and export the database using PostgreSQL and Ubuntu

I need one help. I need to export one database from my postgreSQL which is running in my ubuntu server.
first i typed the below command
sudo -u postgres psql postgres
it gave me the following result.
I checked all database using below command
\list
It gave me the following result.
I needed to connect the 100salons_production database and i connected using the following command and checked the tables.
\connect 100salons_production
\dt
it gave the following result.
Now i tried to check the table values using this command select * from areas but it does not show any result.
Here I need to check the tables results.and also i need commands to export this database and import it in somewhere else. Please help me to resolve this issue.
If you only want to export the database, there is not need to connect to it using the psql tool. Instead, you have to use the pg_dump tool. You can do that like this:
sudo -u postgres pg_dump DATABASE_NAME > dump.sql
Then you should transfer dump.sql to the other computer and import it there.

Why don't connect and disconnect commands work on psql?

I am new to postgresql. I've been using the psql tool to get familiar with the sql commands. Why isn't my psql installation recognizing the CONNECT and DISCONNECT commands?
try this instead: \c is an alias of sorts for connect under psql.
\c mydb;
and
\?
will give you some help as well.
there are no CONNECT or DISCONNECT...
read:
psql and SQL and embedded SQL in C
Postgres SQL commands are different from Oracle SQL commands

How to move/switch one database to another database using shell script(psql)?

How can I move or switch one database to another database using PostgreSQL 9.3 version in shell script(psql)?
Example:
testdb=#
to
mydb=#
If you mean in a script sourced by psql via -f or \i, you can use the command \connect (shorthand \c).
It doesn't just switch databases, it actually disconnects and reconnects. Any SET commands, etc, are not preserved across reconnection.
Simply use below statement:
\c database name