Database is not creating in postgres (psql) [duplicate] - postgresql

This question already has answers here:
In psql, why do some commands have no effect?
(2 answers)
Closed 2 years ago.
I downloaded postgresql installer version 11 from official website for windows.
when i enter psql and try to create database , database doesn't get created but it is creating by pgadmin4 with no problem

You are missing a semi-colon at the end of the line. You need to run:
CREATE DATABASE demo;

you miss semicolon on the end of command.
you should to write CREATE DATABASE demo;
psql by default allows multilines statements, so any statement should be finished by special character and it is semicolon ;

Related

PGAdmin restore remote database [duplicate]

This question already has answers here:
Export and import table dump (.sql) using pgAdmin
(6 answers)
Closed 1 year ago.
Let I first state that I am not a DBA-guy but I do have a question regarding restoring remote databases using PG Admin.
I have this PG Admin tool (v4.27) running in a Docker container and I use this portal to maintain two separate Postgress databases, both running in a Docker container as well. I installed PG Agent in both database containers and run scheduled daily backup's, defined via PG Admin and stored in the container of each corresponding databases. So far so good.
Now I want to restore one of these databases by using the latest daily backup file (*.sql), but the Restore Dialog of PG Admin only looks for files stored locally (the PG Admin container)?
Whatever I tried or searched for on the internet, to me it seems not possible to show a list of remote backup files in PG Admin or run manually a remote SQL file. Is this even possible in PG Admin? Running psql in the query editor is not possible (duh ...) and due to not finding the remote SQL-restore file I have no clue how to run this code within PG Admin on the remote corresponding database container.
The one and only solution so far I can think of, is scheduling a restore which has no calendar and should be triggered manually when needed, but it's not the prettiest solution.
Do I miss something or did I overlook the right documentation or have I created a silly, unmaintainable solution?
Thanks in advance for thinking along and kind regards,
Aad Dijksman
You cannot restore a plain format dump (an SQL script) with pgAdmin. You will have to use psql, the command line client.
COPY statements and data are mixed in such a dump, and that would make pgAdmin choke.
The solution by #Laurenz Albe points out that it is best to use the command line psql here, and that would be my first go-to.
However, if for whatever reason you don't have access to the command line and are only able to connect to this database via pgadmin, there is another solution which you can find here:
Export and import table dump (.sql) using pgAdmin
I recommend looking at the solution by Tomas Greif.

Error in data insertion in heroku psql table using heroku CLI [duplicate]

This question already has answers here:
PSQL [error] - value being recognized as a column
(1 answer)
Simple Postgresql Statement - column name does not exists
(2 answers)
postgres - where in (list) - column does not exist
(2 answers)
Closed 2 years ago.
I am using Heroku CLI to insert data in a database table. I have table name review and these are the columns of it :- (date,verified_reveiws,total_reviews). You can see it in provided image also. when I am executing insert command INSERT INTO review (date,verified_reveiws,total_reviews) VALUES (December, 5, 1169); i am getting this error ERROR: column "december" does not exist, LINE 1: ...iew (date,verified_reveiws,total_reviews) VALUES (December, .... I didn't able to get why this error is coming. psql version I am using is 12.5.

Postgreql: adding database by its files [duplicate]

This question already has answers here:
How to restore PostgreSQL dump file into Postgres databases?
(8 answers)
How restore postgreSQL dump file using pgAdmin?
(1 answer)
How to backup & Restore PostgreSQL database in Windows7?
(3 answers)
How to restore table from dump to database?
(1 answer)
Is it possible to restore a Postgres database by simply swapping out some files for speed?
(2 answers)
Closed 4 years ago.
I have copied database folder from data/base and I wanted to copy them in another computer but in pgAdmin can't find the new database should I do something else besides copying the folder in data/base?
I'm using PostgreSQL 9.3
The problem is that when I try to save database from pgAdmin it freezes, I'm not sure if the database is corrupted or some tables.

Correct PostgreSQL functionality [duplicate]

This question already has answers here:
In psql, why do some commands have no effect?
(2 answers)
Closed 6 years ago.
I have installed Postgres.app in Mac, and I have set the PATH variable to run the psql command.
Now I would like to create a new user and new database for a project that I'm creating. Nevertheless, when I execute a new command in terminal, it doesn't prompt me anything, and I don't know if my command was executed correctly.
Even if I write dummy words, it doesn't tell me anything:
Also, if I want to enter to the postgres user, it doesn't allow me, sending me the next error:
Does anyone know what is happening?.
Regards.
You have to append ; to each of your PostgreSQL - commands.

postgresql: how to use a particular database [duplicate]

This question already has answers here:
How to switch databases in psql?
(15 answers)
Closed 8 years ago.
I am quite new to postgresql and I am looking to timprove. I mostly use MySQL and from what I see already there are a few differences. Under mysql i would want to use or change my database (d1), i simply say the command
use d1;
What do I do under postgres?
I can view the databases and roles using commands such as:
select * from pg_roles;
select datname from pg_database;
Also are there comprehensive online resouces that I can point to?
Thanks
Psql uses short commands prefixed by a backslash to identify 'meta-commmands'; inputs that are for the command shell and not commands to be sent to the database.
You can get a list of these by typing \?
You can change databases in psql by using \c databasename
Here's the psql documentation for the newest release