I have two docker containers running on a linux host. One with a DATABASE and one with an APPLICATION. How can I connect from container APPLICATION to container DATABASE port 5432? For example: I start DATABASE container and bind port 5432 to hosts l
I need to write a query that only counts individuals that have not attended an event previously. Here are the models class Individual < ActiveRecord::Base has_many :attendances, dependent: :destroy has_many :events, through: :attendances end class At
I'm using JOOQ and Postgres. In Postgres I have a column gender: 'gender' AS gender, (the table itself is a view and the gender column is a placeholder for a value that gets calculated in Java) In Java when I .fetch() the view, I do some calculations
I'm learning SQL using PostgreSQL, and I'm trying to modify one of the queries from the PostgreSQL Tutorial website. The original query is this: SELECT film_id, title FROM film WHERE film_id IN ( SELECT inventory.film_id FROM rental INNER JOIN invent
I gonging to change my laravel application database mysql to postgres. I am using raw query Here is my query: select IF (modelno="" OR modelno IS NULL,name,concat(name, " / ",modelno)) as name, id from `models` where `deleted_at` is nu
I have an hstore column in my users table and seem to be unable to set the default key value pairs via migration or psql. I have referred to this question Adding a key to an empty hstore column, but with no success. And as far as a migration solution
I have the following plpgsql function in PostgreSQL: CREATE OR REPLACE FUNCTION func1() RETURNS SETOF type_a AS $BODY$ declare param text; sqls varchar; row type_a; begin code..... sqls='select * from func3(' || param || ') '; for row in execute sqls
I have two servers on the same network which I have live streaming with a master-slave structure. I'm not using any tools like Slony or Bucardo. It's a simple replication process that can be accomplished by changing some parameters in the .conf files
i have two postgres databases on different servers. Both have a 'public schema' with the same tables inside. One of them is used for developing and I am creating new tables of new columns inside some tables. How can i pg_dump the developing DB struct
PostgreSQL do not have feature to insert Save Points in the trigger functions and when there is an exception ( Like exception NO_DATA_FOUND) the entire transaction is rolled back. But instead of rolling back the entire transaction , I just wanted to
I'm often casting query results to user defined types. Consider this simplistic example: test=# create type test_type as (a int, b int); CREATE TYPE test=# create table test_table (a int, b int); CREATE TABLE test=# insert into test_table values (1,2
I have the following schema: CREATE TABLE author ( id integer , name varchar(255) ); CREATE TABLE book ( id integer , author_id integer , title varchar(255) , rating integer ); And I want each author with its last book: SELECT book.id, author.id, aut
I need help crafting an advanced Postgres query. I am trying to find sentences with two words adjacent to each other, using Postgres directly, not some command language extension. My tables are: TABLE word (spelling text, wordid serial) TABLE sentenc
I have written a code in java that help me to generate a pdf . I have used Itext libraries to generate it. This code also consists of database connectivity with postgres. I have used two jar files itextpdf-5.4.5.jar and postgresql-9.0-901.jar. But as
I need to show some records sorted based on modified column (latest activity on top) (Post with new edit or comments at the top) App UI has twitter like 'more' post button for infinite scroll. each 'more' will add next 10 records to UI. Issue is that
Using SQL databases, it is easy to do statistical / aggregate functions like covariance, standard deviation, kurtosis, skewness, deviations, means and medians, summation and product etc, without taking the data out to an application server. http://ww
Question: Updated: Why does inserting a row into table A with a foreign key constraint to table B and then updating the row in table B that the inserted row in table A references in a transaction cause a deadlock? Scenario: reservation.time_slot_id h
tl;dr: We want to add a new table to the database, without losing previous data. First we took a dump of the database using: $ psql -h localhost dbname > dump_file Then we loaded it to our local db. This is working fine. Problem starts: On adding a n
I have spent good amount of time trying to figure it out and I haven't been able to resolve it. So, I need your help please. I am trying to write a PL/pgSQL function that returns multiple rows. The function I wrote is shown below. But it is not worki
I have a multiple devices (eleven to be specific) which sends information every second. This information in recieved in a apache server, parsed by a PHP script, stored in the database and finally displayed in a gui. What I am doing right now is check
I have a table of orders. There I need to find out which 3 partner_id's have made the largest sum of amount_totals, and sort those 3 from biggest to smallest. testdb=# SELECT amount_total, partner_id FROM sale_order; amount_total | partner_id -------
We are running Postgres 9.1.3 and we have recently started to run into major performance problems on one of our servers. Our queries ran fine for a while, but as of August 1st, they have slowed down dramatically. It would appear that most of the prob
This is a build on a question I asked before (without any luck). I have a model where I'm using a string as a primary key: class Employee < ActiveRecord::Base self.primary_key = "employment_id" end This table also contains the Rails default '
Is there a way someone can get the text files that make up the Database I mean the raw text files that you get when you dump the db.? I am thinking the files must be somewhere inside the data directory...How can I get them?They aren't in a text forma
I find myself in a situation that someone else must have got stuck in at some point. Our company runs an in house MSSQL based database, our website then sits on an external server and currently runs MySQL. The problem comes that both databases need t
I am trying to push a simple app up to heroku and run: heroku rake db:migrate But I get the following error: rake aborted! PGError: ERROR: relation "posts" does not exist : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attno
I have a rails app that has been working successfully for months. In a few places I call directly to the database via ActiveRecord::Base.connection.execute( sql_code ) With a recent need to scale, I just added a second server for data processing. I w
Can you please give me an database design suggestion? I want to sell tickets for events but the problem is that the database can become bootleneck when many user what to buy simultaneously tickets for the same event. if I have an counter for tickets
This is probably a super simple question, but I'm struggling to come up with the right keywords to find it on Google. I have a Postgres table that has among its contents a column of type text named content_type. That stores what type of entry is stor
Due to a sudden power outage, the PostGres server running on my local machine shut down abruptly. After rebooting, I tried to restart postgres and I get this error: $ pg_ctl -D /usr/local/pgsql/data restart pg_ctl: PID file "/usr/local/pgsql/data/pos