I have a template of a migration script that we run with new version when needed. It’s something like: As you can see, the myapp.user value (someuser) is used at three places in the script. Is there a more elegant way to use myapp.user in the INSERT? How can I use myapp.user in the DROP TABLE and the CREATE TABLE
Tag: postgresql-9.4
Postgres – calculate total working hours based on IN and OUT entry
I have the below tables: 1) My Company table id | c_name | c_code | status —-+————+———-+——– 1 | AAAAAAAAAA | AA1234 | Active 2) My User table id | c_id | …
How to ignore duplicates without unique constraint in Postgres 9.4?
I am currently facing an issue in our old database(postgres 9.4) table which contains some duplicate rows. I want to ensure that no more duplicate rows should be generated. But I also want to keep the duplicate rows that already has been generated. Due to which I could not apply unique constraint on those columns(multiple column). I have created a
Postgres Like to Full Text Search
I attempting to create a query to find the name other in my sql database. I have a basic like search as follow and would like to use a full text search instead. Like Query SELECT g.*, COUNT(*) OVER(…
Can we define a GROUP_CONCAT function in PostgreSQL?
I have several lines of SQL code for my legacy database with GROUP_CONCAT statements, as in: In PostgreSQL, I can do the same with: I would like to reuse the old SQL as much as possible. So I need to define a GROUP_CONCAT function that internally calls string_agg. Is this possible? EDIT: The linked question is unrelated! My question asks
Postgres Function to insert multiple records in two tables
create table public.orders ( orderID serial PRIMARY KEY, orderdate timestamp NOT NULL ); create table public.orderdetails ( orderdetailID serial PRIMARY KEY, orderID integer …
jsonb query with nested objects in an array
I’m using PostgreSQL 9.4 with a table teams containing a jsonb column named json. I am looking for a query where I can get all teams which have the Players 3, 4 and 7 in their array of players. The table contains two rows with the following json data: First row: second row: How does the query have to look