
sql - PostgreSQL IF statement - Stack Overflow
How can I do such query in Postgres? IF (select count(*) from orders) > 0 THEN DELETE from orders ELSE INSERT INTO orders values (1,2,3);
Postgres: INSERT if does not exist already - Stack Overflow
Nov 1, 2010 · In Postgres version 9.5 or higher you can use ON CONFLICT to avoid errors of contraints like @Arie mentioned above. To know more options related to this INSERT query …
What is the default username and password for PostgreSQL?
My problem is with getting access to the installed PostgreSQL database. The database that gets created during installation is named iviewdb. I read at many forums that the default superuser …
Find the host name and port using PSQL commands
Apr 8, 2011 · I have PSQL running, and am trying to get a perl application connecting to the database. Is there a command to find the current port and host that the database is running on?
Postgresql SELECT if string contains - Stack Overflow
One thing non-intuitive thing is that for postgres, position is 1 based, not 0 based. For example select position ('a' in 'abc') returns 1. And if there is no match it returns 0.
Postgres 15. permission denied for schema public - Stack Overflow
Oct 18, 2022 · Can't create tables in public schema as non-superuser postgres - super user. What I've done: ALTER SCHEMA public owner to postgres; CREATE USER admin WITH …
What is the default password for Postgres - Stack Overflow
I have just installed Postgres 9.3 on Windows 7. The installation completed successfully. It has never asked me to provide the password for postgres user. The service postgresql-x64-9.3 is …
How to set auto increment primary key in PostgreSQL?
I have a table in PostgreSQL with many columns, and I want to add an auto increment primary key. I tried to create a column called id of type BIGSERIAL but pgadmin responded with an …
How to change owner of PostgreSQL database? - Stack Overflow
Nov 30, 2010 · postgres=# REASSIGN OWNED BY old_name TO new_name; This is a global equivalent of ALTER DATABASE command provided in Frank's answer, but instead of …
Extract date (yyyy/mm/dd) from a timestamp in PostgreSQL
May 26, 2011 · I want to extract just the date part from a timestamp in PostgreSQL. I need it to be a postgresql DATE type so I can insert it into another table that expects a DATE value. For …