Questions tagged [psql]

psql is the primary interactive terminal for PostgreSQL. (DO NOT USE THIS TAG for questions targeting PostgreSQL!)

Filter by
Sorted by
Tagged with
0
votes
1answer
42 views

Ident authentication failed for user “postgres”

I am using PostgreSQL12 on Cent0S8, and I am able to connect to PostgreSQL using the command: sudo -u postgres psql However, when I attempt to connect using: psql -U postgres -h localhost I recieve ...
0
votes
1answer
22 views

String search is very slow with OR statement

I have the following tables: product, product_stock, and product_offer I need to optimize the search when looking for a product that is available in product_stock or that is currently on offer. First, ...
0
votes
0answers
12 views

Pgadmin4 : unable to login.Getting error failed to create ssh tunnel

I am using CentOs7, On the command line I login to the unix server via ssh (sshpass -p $PASS ssh linux_user@linux_box_ip ;;) and then give the below command after logging to the linux box. $ psql -h &...
3
votes
1answer
61 views

Reckless behavior of psql \e

psql executes the query buffer no matter what when exiting the editor, even after quitting it - in which case the buffer may hold the most recently executed SQL query now. To reproduce: Start editor (...
0
votes
0answers
36 views

CentOS 8 Unable to connect to PostgreSQL 12 Server

When I attempt to connect to postgres in from my linux command line, I receive the following error: [lloyd@localhost ~]$ sudo -u postgres psql could not change directory to "/home/lloyd": ...
0
votes
0answers
109 views

PostgreSQL 12 problem restoring from pg_basebackup on CentOS8

I have recently created a Postgres backup, and attempted to use this backup, at which point I recieve the following error, when I try to start the server with - start postgresql-12.service, I get : ...
3
votes
2answers
130 views

How to generates VALUES literal expression using a query?

During development and testing VALUES literal expressions are useful because they enable you to store data definition in your SQL query. WITH foobar(foo, bar) AS ( VALUES (1::integer,'a'::text), ...
0
votes
2answers
55 views

How to make psql restore of a database ignore the owner information?

My database is associated with different usernames on the server and on my local machine. Whenever I try to restore it on my local machine from the backup downloaded from the server using the command ...
1
vote
1answer
25 views

How to save database connection information when using `psql`?

I am learning to use psql to work with a postgres database on linux. I can connect using a long connection string, for example by running: psql postgresql://myusername:mypassword@localhost:5433/dbname ...
0
votes
1answer
79 views

in which timezone Psql displays timestamp without timezone (PostgreSQL)?

What I mean is the following: if I create a timestamp without timezone (timestamp) column and store there some value, internally microseconds are stored, but when issuing select this is converted to a ...
0
votes
0answers
45 views

How to use the \i command in SQL-Shell?

I'm new to PostgreSQL and I wanted to use or run a specific file on the SQL-Shell on windows but I`m getting some errors of what I think is not making sense from my knowledge. I ran the following... \...
0
votes
1answer
11 views

Select columns by file containing primary keys

I have a text file with primary keys. Each line contains one primary key. Now I want to select the rows based on the input file. I can not find the right option for psql to do this. What is the ...
0
votes
1answer
72 views

could not connect to server: can't connect postgres on the server to postico on my local

when I connect postgres on the server to postico on my local I get this error could not connect to server: Operation timed out Is the server running on host "http://159.65.65.203/" (92.242....
0
votes
0answers
223 views

Syntax error near & and : in psql

I am getting below errors in sql log of Native Postgres database : psql.bin:G_co-ac_G_grant_ivspc.sql:1: ERROR: 42601: syntax error at or near "&" 2 LINE 1: grant select on ...
0
votes
0answers
31 views

Import table data using multiple sql file in psql

Local Machine(l1): Windows 10 psql Remote Machine(R1): linux EDB(postgres) On my local I have 1000+ sql script containing insert statement . psql is also installed locally . I need to run this sql ...
0
votes
1answer
48 views

Unable to import shapefile into PostGisDatabase - problem of connection

I have been trying to import/load a shapefile into a PostGis database without any success despite many trials and searching an answer in the documentation. Configuration I'm running Windows 64 bits ...
3
votes
2answers
4k views

What does “psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql)” actually mean?

I have a question regarding following output: [nikola@192 ~] $ sudo su - postgres [postgres@192 ~] $ psql dvdrental postgres psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (...
1
vote
0answers
60 views

PSQL console encoding

How can I have a working PSQL console using UTF8 encoding under Windows? I have a Windows server and client. The Postgres 12 database contains tables with content in multiple languages (ex: English, ...
0
votes
1answer
44 views

Relational-JSON overlapping with association [closed]

I have a composed class called sensor that is linked to a main class Node such that: class node is linked with another node to make a communication that produce an event class sensor can as well ...
0
votes
1answer
42 views

psql command, how to enforce certificate check?

I have created a cockroachdb v20.1.0 cluster based on this: https://www.cockroachlabs.com/docs/stable/deploy-cockroachdb-on-premises.html I have also created a test user like this: CREATE USER test ...
0
votes
0answers
22 views

postgres install from homebrew not creating `postgres` user

So, I'm trying to fix my local postgreSQL install to save log4j2 entries. Because the former has been bungled, I decided to reinstall. I ran the following to uninstall: brew uninstall postgresql rm -...
0
votes
0answers
53 views

How do I temporarily set VERBOSITY in psql (where does psql store its variables)?

I'd like to be able to temporarily set VERBOSITY in a .sql script, execute a DO block, and then restore the VERBOSITY setting. However, this does not work: cat test-set.sql \echo VERBOSITY = :...
0
votes
1answer
29 views

possible to specify field enclosure in psql command line?

In psql if I have a field separator of ",", but there are commas in some fields, is it possible to specify a field enclosure character? I have looked through the documentation but I can't find it. ...
0
votes
0answers
24 views

Postgresql connects to database but with another schema owner

I have a database called sommos_development. Working normally, when I run the command \dn on the database, this is the result The Problem The thing is that sometimes, when I reboot my computer and I ...
0
votes
1answer
18 views

How to get latest timestamped result from time series in a join table [duplicate]

I have 3 tables node ---- id ip metric --- id key (str) node_id (FK on node) his_metric ---- id metric_id (FK on metric) value (float) datetime (datetime) Question How to write a query that will ...
0
votes
1answer
17 views

Column containing the word from another column

I am trying to select records in a postgresql where the service column contains usernames. Something like this but not 1 to 1: select service, cash from services where service not in (select name ...
0
votes
1answer
29 views

Query to update the JSON that does not contain a specific key

I want to query a table that has JSON data. The data of the column detail in the table details are as follows. id | 1 detail | { myCompany: [{ email: 'company@company.com', inProfit: true }], ...
0
votes
1answer
44 views

View operation timestamps for long running operations in PSQL console

When I do long running queries, I tend to use tmux and a psql console. It will not show me any output of when some operation was started or completed. How can I get the psql console to show some ...
2
votes
1answer
65 views

postgresql set variable not working with command option

Has anyone a solution for this issue (tested on postgres v12) I would like to use the psql variable option in conjunction with command like this: psql -v env=test -c "SELECT :'env';" but this ...
0
votes
1answer
153 views

Shell script - psql run multiple statements from a variable one by one in one transaction

Im preparing a shell script to generate analyze command and all the commands will go to a variable. echo $analyze_query analyze tbl1; analyze tbl2; analyze tbl3; Now I want to run one by one, and ...
0
votes
0answers
324 views

Unable to connect postgresql server from pgAdmin4, showing error - 'ServerManager' object has no attribute 'user_info'

I am trying to connect a remote postgresql database server(RHEL7.5) through pgAdmin4 from my windows10 pc, but it is showing an error 'ServerManager' object has no attribute 'user_info'. I have ...
0
votes
2answers
49 views

declare variable in bash script set var=“psql -c ”select * from someting" and execute var

I am searching for a way to integrate psql statements in bash scripts for devops reasons. The simplest way I would do that is: CMD='psql -c "DROP DATABASE restore_database;"' then use a bash ...
1
vote
2answers
247 views

psql ^C takes long time to cancel query [closed]

I am using psql to query a large database. and (understandably) many queries that I type in take a long time. I typically want to cancel these queries and so I enter ^C, and psql responds with the ...
0
votes
0answers
10 views

how do I generate a series starting from the last id in the table, generate_series(last id, 10000)

how do I generate a series starting from the last id in the table, generate_series(last id, 10000)? Say the last id is 101 in the table I would like to generate ids 102-10000 in the table. Currently I ...
6
votes
1answer
226 views

Cannot induce exit code 3 from psql

The docs page states (emphasis mine) Exit Status psql returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g. out of memory, file not found), 2 if the ...
0
votes
2answers
213 views

barman & Dockerized PostgreSQL: check timeout: FAILED (barman check command timed out)

I am trying to configure barman to backup a PostgreSQL 11 database running inside a Docker container. barman v2.10 is installed directly in the Ubuntu 18.04.3 host machine. barman check pgsql gives ...
0
votes
1answer
17 views

Fail to copy all PostgreSQL databases between servers although there is no error message

I want to copy all databases from PostgreSQL 9.3 on Server-1 (Windows 7) to an empty PostgreSQL 12.0 on Server-2 (Windows Server 2012 R2). The steps are as follows: On Server-1: C:\Program Files\...
0
votes
1answer
21 views

Constraints between tables on a variable

im aiming to add a constraint on the number of bicycles allowed to be stored in each terminal - the number differing between terminals. These are my original tables create table terminal( ...
0
votes
2answers
49 views

PostgreSQL dump distinct column without memory consumption

I'm trying to dump csv of distinct varchar(43) column to file, table has around billion rows, select distinct command either runs out of memory and command is aborted or server just closes all ...
0
votes
1answer
334 views

How to setup an ssh connection to a postgres 12 db using dbeaver

I am currently in the process of trying to connect to my local postgres 12 db. In the past (9.3/9.6) you were able to edit the .pg_hba file to modify which connections were allowed but that file doesn'...
4
votes
2answers
61 views

How can I rerun a statement from server logs without manual editing?

I have some statements in my logs like this: SELECT to_char("version_downloads"."date", $1), SUM(version_downloads.downloads) FROM "version_downloads" WHERE "version_downloads"."version_id" IN ($2, $...
1
vote
1answer
17 views

set -x equivalent for the Postgres cli/console/prompt/repl

Is there a "set -x" for the Postgres prompt/repl ? In bash when you want to execute a set of commands, and come back to check it after lunch you can do set -x command1 command2 command3 and bash ...
0
votes
0answers
55 views

Single-tenant to multi-tenant: restore old database to schema in new database

I have a Django app which uses Postgres as a database w/ the django-tenants package providing multitenant functionality. This is a migration from what was originally a single tenant database with just ...
0
votes
2answers
927 views

Importing plain (raw) files into a postgres table (bytea and large objects)

What is a good way to insert/copy plain files into a postgres table, preferrably using the psql command-line? In my case the files are a bunch of eMails from Maildir archives, so I tried to use COPY: ...
0
votes
0answers
59 views

advice : restore a table with PostgreSQL in a database

(dba beginner) As an exercise, I test different methods to restore all or part of a database. I have 2 dumps of a table: the first one in sql format, the second one in custom format. So I use psql in ...
-1
votes
1answer
201 views

COPY … FROM STDIN command failing on null values exported as “\N”

I initiated a table dump and wherever the NULL value comes, the dump file has \N for that. During the restore I'm getting this error. invalid command \N The database encoding is UTF8. I took ...
0
votes
1answer
99 views

Postgresql equivalent of --i-am-a-dummy

MySQL's command line tool has a flag --i-am-a-dummy that sets execution limits: With --safe-updates, you can modify rows only by specifying the key values that identify them, or a LIMIT clause, or ...
1
vote
2answers
525 views

Exporting table data into csv format from server to local [closed]

I have connected to remote server and trying to export a table data to local using the command: copy finance.coa to 'localusername@172.16.1.44:/home/kedarisettyakhiles/akki.csv' DELIMITER ',' CSV ...
2
votes
0answers
296 views

Use or include external schema in search_path on Redshift

Narrative I have a sql script that creates a bunch of tables in a temporary schema name in Redshift. I don't want to repeat the schema name a bunch of times, so I would like to do something like the ...
0
votes
2answers
41 views

Postgresql - roles without linux accounts?

Basic question: what I'm reading describes how to create linux users in parallel with postgresql roles. However, I don't see the value in creating any of these users in linux - I just want to create ...

1
2 3 4 5 6