Questions tagged [psql]

Primary interactive shell for PostgreSQL. NOT a synonym for PostgreSQL.

psql is a terminal-based client to PostgreSQL, that's packaged with the software. It lets you edit queries interactively, issue them to PostgreSQL, and see the results. You can read and write to / from files and use it for scripting.

Additionally, psql provides a set of meta-commands and other shell-like features to facilitate writing scripts and automating a wide range of tasks.

Questions with this tag should probably be tagged , too.
But only questions dealing with the command-line interface should be tagged .


Questions referring to the procedural language "psql" for the Firebird database should be tagged with

3588 questions
1
vote
0 answers

how to access psql database in mocha js test of javascript?

I have javascript code for client side and stores some data in server side in psql.I unit tested the script code using mocha js.While running, the test data is stored in postgres database. I need to remove the test data from database in mocha…
shan
  • 11
  • 2
1
vote
2 answers

Sqoop: how switch off Prepared Statements?

I use Sqoop 1.4.5-cdh5.4.2 and Postgresql. If Sqoop connects directly to the database - all right. But need use Sqoop over pgbouncer, and I have problem with this. In pgbouncer you can not do prepared statements transaction mode. ... connect…
1
vote
1 answer

Concatenate varchar[]'s in PostgreSQL, keeping distinct values

I've got a database containing network assets, each of which can have multiple hostnames. Sometimes, a we'll mistakenly create two records for the same machine, and then later have to "merge" these assets. Part of this is combining their lists of…
Andrew Rueckert
  • 4,858
  • 1
  • 33
  • 44
1
vote
1 answer

trying to locate output file from postgresql \o -o command

I am making an automated script from terminal that creates a file with the output of \l But I do not know where the \o command in postgresql prints out the file that it has made. The documentation doesn't inform where. I did read this, but no…
MichaelR
  • 152
  • 8
1
vote
2 answers

Get count of test runs along with the time when it started

I have a table say test_data which looks like this test_id | test_timestamp | test_value 123 | 2016-05-27 14:23:57.634119 | 45 123 | 2016-05-27 14:23:57.634119 | 11 123 | 2016-05-27 14:23:57.634119 | 12 123 …
sid
  • 95
  • 2
  • 11
1
vote
1 answer

Recover changes to Postgres function

I was editing a Postgres function using \ef and changed the RETURN type. Didn't realize this was a no-go for saving it. mattswheels=# \ef fib mattswheels-# \g ERROR: cannot change return type of existing function HINT: Use DROP FUNCTION…
some1
  • 1,547
  • 8
  • 26
  • 45
1
vote
3 answers

What's wrong with my Postgres query inside of golang (LIKE matching)

I've seen a very similar problem here, but I'm not certain what the pipes do in the command, and it didn't work for me anyway. So, here's the code I've tried. rows, err := db.Query(fmt.Sprintf("SELECT * FROM mytable WHERE mycolumn LIKE…
trueCamelType
  • 2,198
  • 5
  • 39
  • 76
1
vote
1 answer

when are newlines in psql command line strings significant?

I was trying to break a long command line involving psql command string (i.e. psql -c),and this seems to cause errors. For example, with PostgreSQL 9.5 and Ubuntu 16.04: $ psql -c "\\dt" works fine, while $ psql -c " > \\dt > " generates: ERROR: …
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

psql extra command line argument

Can someone tell me why I get the error extra command line argument here? When I use -f and give it the full path to the sql file it works fine. I would like to use a relative path instead so I was trying to use the \ir command. psql -c \c…
reutsey
  • 1,743
  • 1
  • 17
  • 36
1
vote
1 answer

Java runtime exec psql logging

I can run the following via bash and it will work: psql -h -p -d -U -w -v username="'user'" -v rid=2 -c '\ir ../../../resources/sql/myFile.sql' When I try to run the command in Java using the following, it doesn't…
reutsey
  • 1,743
  • 1
  • 17
  • 36
1
vote
2 answers

Ruby on Rails Params set recipient and sender with users_id

Have a recipient and sender, both of the same class(Message) for a messaging system in rails. Want to set the params for both i.e. if user creates a message sender by default is the user_id and recipient will be the contact selected from the users…
blastoff
  • 31
  • 7
1
vote
1 answer

PSQL function help - date format issue

Just trying to clean up some functions someone else has done in a postgres. Would anyone know what the following does? It was working, but the date format changed when it started coming in as '1999-09-07 16:30:00.000' I don't know what the previous…
emraldinho
  • 475
  • 8
  • 23
1
vote
2 answers

postgresql escaped quotes still escaped in DB

Just had to import some data in my postgreSQL db with sometimes single quote escapes. Everything is fine, but at the end I still have my '' escapes in my DB values. before import : L'Auberge D'Aillane after import (when I do a "SELECT name from…
Alex Pereira
  • 916
  • 1
  • 9
  • 17
1
vote
1 answer

postgres find whether json path exists

I want to find whether a specific path exists in a jsonb value using a psql query. For example, for this path: {"333":"opc":["1333"]} This value should return true: '{"333":{"opc":[{"1333":"3787"}]}}' But these values should return…
Sam Sam
  • 27
  • 3
1
vote
1 answer

redshift sql current_date get_date() performance issue

I would like to know whether using the current_date or get_date() function on redshift SQL would lower the query performance compared to using '2016-05-05' directly, for example. Example 1: select * from table a where time >= current_date -…
hleslie
  • 11
  • 2