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

Tmux: Error messages from another window are getting overlaid over Vim's buffer

I am using Tmux for terminal window management. In my usual workflow vim and PostgreSQL's psql session are open in separate windows. From time to time, if i get an error after executing a query in psql, its contents are dumped onto vim's buffer…
siphiuel
  • 3,480
  • 4
  • 31
  • 34
1
vote
2 answers

Are Postgres constrains per table or db?

Can I have two tables with different constrains that are names the same - that is: Table A with constraint C Table B with constraint C The constrains are different Thanks!
Vitali Melamud
  • 1,267
  • 17
  • 40
1
vote
2 answers

psql how do you select from a composite array

CREATE TYPE complex AS ( start_time timestamp, amount int, ); Given a variable my_complexes complex[] how do you query it like a table? SELECT amount FROM my_complexes; Gives "relation does not exist". SELECT mc.amount FROM (SELECT my_complexes)…
Jordan Morris
  • 2,101
  • 2
  • 24
  • 41
1
vote
1 answer

Django 1.8 Squashing migrations

I have some questions on Squashing in Django 1.8. I've squashed a few migration files into one but not quite sure how to do the 2 actions as specified in the djangoprojects docs. After this has been done, you must then transition the squashed…
SimonK
  • 73
  • 1
  • 5
1
vote
1 answer

Postgres 'psql' command is not working in ubuntu

I am new to psql. In terminal. I entered the following command psql -U postgres I am facing the following error: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on…
Monisha
  • 89
  • 1
  • 6
1
vote
3 answers

insert string into text [] column

I have the following issue. I will receive input as a text from a webservice to insert into a certain psql table. assume create table test ( id serial, myvalues text[]) the recieved input will be: insert into test(myvalues) values…
Taher Galal
  • 297
  • 4
  • 23
1
vote
1 answer

Sorting posts by most liked over the past 24 hours on Ruby on Rails

Currently my app is using the acts_as_votable gem and the default_scope is set to order posts by most up votes. All votes are cached, as seen in the acts_as_votable documentation. However after time my content will get stale, so I would like to have…
Steez
  • 219
  • 5
  • 17
1
vote
2 answers

Postgres URI generation with sequences?

So I'd like to create a column in a table in a postgres databse that auto increments a number and places it after some data. AKA protocols table: name | uri | _____________________________ someProtocol | /protocol/1 otherProt |…
thisisnotabus
  • 1,949
  • 3
  • 15
  • 31
1
vote
2 answers

Python: PSQL: Generate list from query

I am trying to retrieve some data from a table and output it as a list. The problem is that the resulting list is not in the correct form. This is my table: My code: cur.execute("SELECT tegebruikentags FROM tagstegebruiken WHERE wel_niet_lezen =…
RobbeM
  • 727
  • 7
  • 16
  • 36
1
vote
2 answers

Restoring .dump file - "Permission Denied"

I am setting up a website and am having some trouble restoring a database .dump file. I am using centos7, selinux, postgresql 9.4, and apache2. This is my pg_hba.conf file. This is the command I am trying to move the dump: psql…
bluepanda
  • 382
  • 2
  • 13
1
vote
1 answer

psql syntax error at or near "+"

I'm trying to use arithmetic calculation: \set startSmallOffset 1000000 \set traineeNext :startSmallOffset+2000 ALTER SEQUENCE record_trainee_id_seq RESTART WITH :traineeNext The error: ERROR: syntax error at or near "+" LINE 1: ALTER SEQUENCE…
Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38
1
vote
2 answers

Find the users pointing to my database postgresql

I logged into the psql console to delete some databases, but it gives me this error: ERROR: database "production" is being accessed by other users DETAIL: There is 1 other session using the database. How should I find the users pointing to my…
Hellboy
  • 1,199
  • 2
  • 15
  • 33
1
vote
1 answer

Save psql output to a local file over ssh?

I connect to a sever over ssh and run psql I want to make a database extraction from the server but I can't save files on the remote because I don't have write-permission. How can I save it locally?
Himmators
  • 14,278
  • 36
  • 132
  • 223
1
vote
1 answer

Issues with GRAILS UUID and PSQL

I am trying to use UUID2 generator on grails 2.4.4, PSQL version 9.4.4. My current model setup is. class ClassA { UUID id static mapping = { id generator:'uuid2', name:'uuid2', type:'pg-uuid' tablePerHierarchy false …
ChUck_PrOg
  • 331
  • 7
  • 16
1
vote
1 answer

psql max group by just for some columns

I have a problem in a psql query. I don't know how to select only the maximum value from a subset of two columns. It's very hard to explain the problem without an example, so I write one: I have a table like that: Athlete | Category | Points …
leonardo vet
  • 119
  • 14
1 2 3
99
100