Click here to Skip to main content
15,885,278 members
Everything / Database Development / PostgreSQL

PostgreSQL

PostgreSQL

Great Reads

by Evoluteur
Generic REST or GraphQL endpoints for CRUD and more, written in JavaScript, using Node.js, Express, and PostgreSQL
by RickZeeland
PostgreSQL notifications Windows Forms application
by Arthur V. Ratz
Create a Python web-app using Flask and PostgreSQL server, and run it in Docker
by dsuryd
Combine PostgreSQL logical replication feature with dotNetify to broadcast data changes to your website in real-time

Latest Articles

by GabrieleTronchin
A simple implementation of MartenDB. MartenDB is a .NET Transactional Document DB and Event Store on PostgreSQL. For more information about MartenDB
by Farzad Niknam B
Web app creation using .NET 7.0 and ASP.NET Core
by JBartlau
This article demonstrates how Report Server offers a distribution of reports that save time, increase efficiency, and reduce potential errors.
by Jeffrey T. Fritz
Migrate Azure Postgres database to a Flexible Server

All Articles

Sort by Score

PostgreSQL 

11 May 2022 by Evoluteur
Generic REST or GraphQL endpoints for CRUD and more, written in JavaScript, using Node.js, Express, and PostgreSQL
15 Oct 2020 by RickZeeland
PostgreSQL notifications Windows Forms application
24 Aug 2018 by Arthur V. Ratz
Create a Python web-app using Flask and PostgreSQL server, and run it in Docker
4 Aug 2021 by dsuryd
Combine PostgreSQL logical replication feature with dotNetify to broadcast data changes to your website in real-time
6 Jul 2022 by DiponRoy
Quick start example to run DB and clients in docker
20 Mar 2017 by AlexeyYakovlev
A library to emulate Oracle-style permanent temporary tables in the PostgreSQL database
19 May 2022 by André Marcos (Advisor), GracianoSouza
React Native, Node.js and PostreSQL, a PERN stack to develop an app to support the lost pets searching process
27 Oct 2023 by Richard Deeming
Quote: Adding ORDER BY clause gives the similar order and data every time but I do not need that for the requirement. Except you do need that. If you don't specify an explicit order for the results, then the order is undefined. The DBMS is...
2 Nov 2015 by Guni Van
Mapping your database with C# object class, then make typed-safe query like SQL syntax
18 Oct 2020 by JawadHasan
Use NoSQL database functionality from within a Relational database system
8 Dec 2022 by Jerome Vonk
Granola is a web app for tracking your expenses with custom categories, reports and charts
1 Nov 2022 by Tomas@PawSQL
How to cope with all scenarios regarding NULL value handling in your daily work
19 Aug 2023 by Farzad Niknam B
Web app creation using .NET 7.0 and ASP.NET Core
27 Aug 2015 by F-ES Sitecore
You can't have duplicate values in the primary key or else it wouldn't be a primary key.
18 Nov 2015 by Softarex Technologies, Inc.
Step-by-step case shows how to optimize a web application using new technologies which can easily increase the performance
18 Feb 2016 by debashishPaul
How to Get 'serial' value of the Inserted Record and Use with a Variable in PostgreSQL
3 Feb 2023 by JBartlau
This article demonstrates how Report Server offers a distribution of reports that save time, increase efficiency, and reduce potential errors.
1 May 2018 by Pero Matić
A Dockerized proof of concept application using React, Node, Python, GnuCOBOL, PostgreSQL, and Docker.
4 Dec 2023 by Richard Deeming
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation/interpolation to build a SQL query. ALWAYS use a parameterized query. Fix that, and you'll also fix your error. cmd.CommandText = "INSERT INTO mps_errorlog (idError,...
10 May 2013 by RaisKazi
Have a look at below simmilar Question-Answer thread.http://www.postgresql.org/message-id/20091020172452.GA10593@tuxHope it helps.
27 Feb 2014 by Sergey Alexandrovich Kryukov
What you want is not how it should be done.This is done via the use of satellite assemblies. The idea is: you develop all the code in one language which is used for fallback in case no closer localized resources can be found. Usually, English is used, even if the code is developed in not an...
27 Feb 2014 by Maciej Los
PostgreSQL:Using ltree for hierarchical structures in PostgreSQL[^]SQL - MS SQL ServerHierarchical Data (SQL Server)[^]Hierarchies WITH Common Table Expressions[^]
10 Sep 2014 by Afzaal Ahmad Zeeshan
You need to develop a logic to determine what type of user has logged in, inside your Database create a new column, to save whether the user is a teacher or a student. It can be a single Bit column, with name of IsTeacher, and you can save 1 if the user is a teacher or 0 if the user is a...
10 Sep 2014 by kbrandwijk
myreader["type"] would contain the value return from the database for the user. Based on that type, you can put either a switch or if-else around showing the Main form, which can either be MainForm1 or MainForm2.However, if you expect a single result, you could change:while...
16 Feb 2017 by User 11060979
General Q, General A:"Now, the solution I have thought of is highly inelegant."No, this is not inelegant, it is the pragmatic way to have history data consistent."I have considered saving the client details for every sale in the Invoice table, and the item details in...
26 Mar 2018 by Maciej Los
Check this: PostgreSQL: Documentation: 9.5: SELECT[^]
2 Apr 2018 by RickZeeland
I seldom use pgSQL, and mostly use it from .NET with the NpgSQL driver, but here are some examples. Sadly I got no output displayed in the pgAdmin window, but saving the results to a file worked. Simple example from PostgreSQL wiki[^] --DROP FUNCTION getemployees(); create function...
8 Apr 2019 by Steve Grattan
You say you have tried this. I assume this is an attempt at the syntax (rather than it returning incorrect results) as there are errors: 1. Enrollement is not a table name - should be Enrollment 2. Program_Year_When_Enorolled - this is a misspelling isn't it? 3. avg_third_year_marks has been...
24 Jun 2019 by k5054
Try UPDATE my_factors SET factor = my_factors.to_weight/dni_totals.dni_sum FROM dni_totals WHERE my_factors.transport_order = dni_totals.to_id; PostgreSQL doesn't like the SET table.column syntax, so you use the unadorned column name there. Additionally, you only need to specify...
3 Jul 2019 by Cloudster
Deploy a 360 image gallery with Django, Bootstrap, Python, A-Frame, and PostgreSQL
24 Mar 2021 by Arctype SQL
Using pg_notify in Postgres alongside the NOTIFY and LISTEN syntax is all that's needed to build a real time updating dashboard
15 Oct 2021 by Greg Utas
Let's say you have 1M characters and that each character requires 1KB of data. That's still only 1GB, so just shadow the entire database in memory and only do commits when necessary. Frequently re-importing the data after asking the database to...
20 Oct 2021 by Rick York
I use VS19 also and I make libraries all the time, no pun intended. Portability to other environments is of zero concern for me so I just use VS19's built-in settings to make it happen. I select a configuration type of static library which is...
27 May 2019 by DiponRoy
Creating or using cursor in SQL-Server, Oracle, MySQL, PostgreSQL databases
29 Jan 2024 by Peter_in_2780
Your array_fill() is the culprit. Take a look at what you are putting after VALUES ( implode(',',array_fill(0,count($col),implode(',', $input))) It's effectively evaluated right to left because of the nested function calls, so take the first...
19 Mar 2024 by OriginalGriff
Nobody can guarantee you "a fraction of a second" to add a million rows to a DB, PostgreSQL or not - it will depend on far too many factors: the computer(s) that the DB engine is running on, the activity level on the DB, the connection between...
20 Mar 2012 by Wayne Gaylard
Well, you are saving the image path to the database and not the image itself. When the data comes back from the database to fill the adapter, it is just a string with the path, and has no idea that it is supposed to be an image.
13 Sep 2012 by Prasad_Kulkarni
Refer: Postgres and recursion[^]
1 Jul 2013 by Nirav Prabtani
Try this...:)http://www.postgresql.org/docs/9.2/static/datatype-xml.html[^]http://www.postgresql.org/docs/devel/static/functions-xml.html[^]
6 Jul 2013 by Radu-Stefan Zugravu
Hi,I imported a large area of OpenStreetMap's planet.osm file into a postgresql database. The database contains a table called nodes. Each node has a geometry column called geom and a hstore column called tags. I need to extract nodes along a line that have certain keys in the tags column....
21 Feb 2014 by CHill60
Well if you really want to add spaces to make up the length then you could do this ...// method 1 - pad right with spaces firstper = per.PadRight(16);// using TrimEnd in the next line effectively implements your requirement "if it's more than 16 then nothing"len1 = per.Substring(0,...
5 Sep 2014 by Erik Vullings
Converting a PostGIS table to GeoJSON
23 Nov 2014 by OriginalGriff
"i dont know sql so asked."Then learn it. We are not here to do your work for you. It doesn't quite work like that.If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.But be aware: you get what you pay for. Pay peanuts, get monkeys.
1 Dec 2014 by Maciej Los
There is few ways to improve performance of sql query. See:http://www.infoworld.com/article/2628420/database/7-performance-tips-for-faster-sql-queries.html[^]http://www.developer.com/db/10-ways-to-improve-sql-query-performance.html[^]At the first look, reducing the numbers of subqueries...
1 Dec 2014 by Kornfeld Eliyahu Peter
Your query full of sub-queries, even nested.Remove those sub-queries and replace them with LEFT JOIN (or INNER JOIN where fits better), that will help you...
9 Dec 2014 by Sinisa Hajnal
Just add ISNULL to your balance and it will create two zeros which will be eliminated by DISTINCT. I hope this helps (change in bold)SELECT distinct ecpc.ecpclaim_key AS claim_key ,ecpc.ecpclaim_patient_last_name AS patient_last_name ,ecpc.ecpclaim_patient_first_name AS...
21 Dec 2014 by Mehdi Gholam
Read the documentation : http://www.postgresql.org/docs/9.1/static/backup.html[^]
5 Feb 2015 by Joshua Ngatia
I have a postgres db 9.3 which i need to do a manual backup from the front end . It seems to work but the dump files are always 0kb and cannot be used for restore:Sub executeCommand(ByVal commandType As String, ByVal commandSentence As String) Try Dim info As New...
25 Jun 2015 by Suvendu Shekhar Giri
In SQL Server you can do it likeTo get the first number,SELECT CAST(DATEPART(YEAR,GETDATE()) AS VARCHAR)+'/'+RIGHT('0'+CAST(DATEPART(MONTH,GETDATE()) AS VARCHAR),2)+'/'+RIGHT('0'+CAST(DATEPART(DAY,GETDATE()) AS VARCHAR),2)+'/'+'001'You can make it dynamic to check with some field of a...
7 Jul 2015 by Suvendu Shekhar Giri
If you are copying between two tables in the same database, you can do something likeINSERT INTO table2(column_name(s))SELECT column_name(s)FROM table1;Example:INSERT INTO table2SELECT * FROM table1;Check this tutorial-SQL INSERT INTO SELECT Statement[^]Hope, it helps :)
18 Aug 2015 by Suvendu Shekhar Giri
Have tried searching this in google[^] prior to post here?To execute a query in remote database you can use dblink[^]insert into mytableselect *from dblink('dbname=postgres hostaddr=xxx.xxx.xxx.xxx dbname=mydb user=postgres', 'select a,b from mytable') as t1(a...
28 Aug 2015 by Patrice T
Answer: No it is not possible.The wording Primary Key imply non duplicate values, it is by design !You can have duplicate values in Non Primary Key, it is the only way.
3 Sep 2015 by Suvendu Shekhar Giri
This is not purely supported by PostgreSQL (as far as I know), you can get results combined if they return the same row type. You can do that either through a UNION ALL or a function like following-CREATE FUNCTION test() RETURNS SETOF first_table AS$func$BEGINRETURN QUERYSELECT *...
2 Feb 2016 by pravinchopade
I have PostgreSQL 9.5 and Visual studio 2010; I'm trying to connect to database through C# application; below is the codestring connstring = "Server=127.0.0.1;Port=5432;User Id=[UserID];Password=[UserPassword];Database=[Database];";NpgsqlConnection conn = new...
2 Feb 2016 by StM0n
Like described in our conversation ;)Download the approprioate version via nuget and reference it. in your case, it's 2.2.7 which provides a version for .net3.5Glad I could help
12 Jun 2016 by aarif moh shaikh
Here is two way to resolve your problem .1. You can use the EXCEPT or INTERSECT set operators for this. for example SELECT id, name FROM master.dbo.testEXCEPT -- or INTERSECTSELECT id, name FROM test.dbo.testings2. Use of Information Schema select * FROM questions_table...
22 Jun 2016 by CHill60
Read the documentation!PostgreSQL: Documentation: 9.1: Declarations[^]
5 Jul 2016 by Suvendu Shekhar Giri
If you have tried something and that didn't work then we could have help if you had posted the error or issue details. But as it seems, you are yet to try it, we only can suggest some tutorials or articles which you could have find if searched in google with proper keywords.Here is an...
31 Jul 2016 by RickZeeland
When I use the following, it works, but of course many will protest against not using a parameterized query:public static void CreateUser(NpgsqlConnection pgConnection, string user, string password){ try { string sql = string.Format("CREATE USER {0} LOGIN PASSWORD '{1}';",...
10 Nov 2016 by Member 10256268
SELECT string_agg( distinct a || '-' || b , ',' ORDER BY a,b) FROM table;The above sql giving error ERROR: in an aggregate with DISTINCT, ORDER BY expressions must appear in argument listHow to resolve the issue.What I have tried:I have tried with above sql which mentioned in...
10 Nov 2016 by jgakenhe
With this kind of error, I typically use a subquery to do my dirty work. After playing around with this for a few minutes on SQL Fiddle[^][^], I came up with the SQL script below.CREATE TABLE item(itemid integer,item character varying(50));INSERT INTO item(itemid, item)VALUES (1,...
13 Mar 2018 by Paolo Parise
Dockerized Postgre to improve coupling between versioned codebase and DB schema
5 Jan 2017 by King Fisher
I have written a query which will check for a record existence, If condition is true, it will update else it will insert a new record. The problem is while inserting, It returns Query returned successfully: 1 rows affected, 200ms execution time.but when updating It returns Query returned...
7 Mar 2017 by RAMASWAMY EKAMBARAM
Method AYou can define column 'IsCurrent' of table 'STOCK' as NULLable and define a UNIQUE constraint on the column.Whenever you insert a record, generate 2 SQLs:(1)update STOCK set IsCurrent = NULL where item = (2)insert into STOCK values (, , ,...
23 Jul 2017 by Harmen Stoopendaal
See for solution this repo: GitHub - Harmen1969/SignalR-Postgresql-: Real time push notification using SignalR and PostgreSQL[^]
3 Apr 2018 by Wendelius
Not sure if I understand the question correctly but should you return only a single value. Something like CREATE OR REPLACE FUNCTION max_emp_id_select() RETURNS integer AS $BODY$ DECLARE p_emp_id integer; BEGIN SELECT COALESCE(max(emp_id),0) INTO p_emp_id FROM Employee; RETURN...
30 Apr 2018 by RickZeeland
Maybe PostgREST might be of interest to you: GitHub - begriffs/postgrest: REST API for any Postgres database[^] This is a self hosted webserver that can turn any PostgreSQL database into a REST API, which is not a website of course but can ease development a lot. There is also an excellent...
5 Feb 2019 by RickZeeland
That is hard to tell without having access to the code, but the error is QT related. See information here: SQL Database Drivers | Qt SQL 5.12[^] Quote: instruct the ODBC driver to behave as a 3.x driver by setting the connect option "SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3" before you open your...
11 Feb 2019 by RickZeeland
You need to use the proximity operator So that would be: "Jack Jill" See examples here: Mastering PostgreSQL Tools: Full-Text Search and Phrase Search - Compose Articles[^]
17 Apr 2019 by MadMyche
In PostgreSQL, Time(p) is a Time type with a precision of p, where precision is a positive number Precision levels of 0-6 will have the Time stored as an Integer Levels 7 and above will store the Time as a floating point. Is (MS) SQL Server, the type would be the same Time(p), however; the...
10 Jul 2019 by Maciej Los
Quote: I've database(DB-1) which has 2 very large tables, one table having 25 GB of data and another is 20 GB of data. which cause major performance issues even i have indexes. Seems, your question is not about archiving old data, but how to "shrink database"? Have you seen this: PostgreSQL:...
24 Jul 2019 by Richard MacCutchan
Did you try the Postgresql documentation: PostgreSQL: Documentation: 8.4: Cursors[^] ?
15 Dec 2019 by Ahmed Bouchefra
A Django 2 CRUD example application using generic class based views using the latest Python 3.7 version
20 Feb 2020 by raddevus
You need to JOIN the two tables. Here is a very good explanation: PostgreSQL - JOINS - Tutorialspoint[^] However, your tables need a column that is used for the join -- a common column (primary key in master and foreign key in the other). For...
17 Jul 2020 by Maciej Los
I'd strongly suggest to read this: PostgreSQL - How to Return a Result Set from a Stored Procedure - SQLines Open Source Tools[^]
7 Aug 2020 by CHill60
Your Create Function code is incorrect - see PostgreSQL: Documentation: 9.4: CREATE FUNCTION[^]. You have not defined the column list. For an example see PL/pgSQL Function Returns A Table[^]
7 Oct 2020 by Gerry Schmitz
Move to Entity Framework Core. The level of support (docs) compared to EF 6.0 should make EF 6.0 a non-starter (for pgsql). Getting Started | Npgsql Documentation[^] Entity Framework 6 | Npgsql Documentation[^]
20 Jun 2021 by Dave Kreskowiak
127.0.0.1 is LOCALHOST. That means your connection string assumes the SQL server and the web server are running on the same machine.
13 Sep 2021 by RickZeeland
As it says here: The Complete Oracle to PostgreSQL Migration Guide: Move and convert Schema, Application & Data[^] Quote: PostgreSQL does not have packages but using schema architecture, functions and procedures can be grouped. Use the “orafce”...
13 Sep 2021 by Wendelius
PostgreSQL does not have a similar object type as a package in Oracle so you need to break the package into separate procedures and functions. What comes to the naming, I don't see any specific reason to retain the name of the package as a prefix...
15 Oct 2021 by Member 15329613
1. It would be faster to do the update in SQL, rather than pull all records into C++ and rewrite the data to the database. 2. If you are going to stick with C++, do not do SELECT *. Select just the specific field(s) you need. 3. Some games...
15 Oct 2021 by KarstenK
The in memory operation is an excellent idea, but also try to optimize your code. Your string building in the exec statement isnt good. Better is too use one sprint or even better use all information as strings and so avoid type casting. Also use...
7 Jan 2022 by CHill60
Which ever "structure" you use to display the results you cannot get away from the fact that the query will return your data as |id | versions| |----|-------- | |101 | 0.0 | |101 | 1.0 | |101 | 2.0 | |101 | 3.0 | It has to,...
8 May 2022 by OriginalGriff
Don't. You can't really automate that successfully without having a lookup table for each possible address in the country. For example, where do you break "peach pine road lake havasu city arizona" that gives you three segments "peach pine road",...
18 Sep 2022 by Richard MacCutchan
See postgresql workdays - Google Search[^].
22 Nov 2022 by CHill60
When you press '1' it should be asking you for the default value to apply. Ctrl-C will terminate your program without further processing taking place. Quote: So how should this be fixed? You have several options: 1. Change the database so that...
22 Nov 2022 by Richard MacCutchan
Add a default parameter to the name field in your Author class thus: name = models.CharField(verbose_name='Имя автора', default='no name', max_length=200, validators=[validators.RegexValidator(regex='^.*em$', message='Wrong')])
14 Feb 2023 by OriginalGriff
How do you know it is correct? What value did you store in the DB? How did you store it? What value is returned by the SELECT? Do the rows even exist? Are you even connected to the correct database? You need to look at exactly what is happening...
20 Feb 2023 by Richard MacCutchan
See Learn about building, deploying, and managing your apps on Heroku.[^]
4 Jul 2023 by Richard Deeming
Quote: I just want to count the results I can't return such data to the user there is no means I can count these values depending on these conditions provided Your code is loading all 4 million matching records into a list, simply to return...
23 Aug 2023 by OriginalGriff
We can't tell: we have no access to your system to see what might be going on - and your command requires files in specific places which may not be valid for anyone else's PC. So it's going to be up to you - I'd start by removing this line:...
26 Oct 2023 by Gerry Schmitz
Add a "timestamp" to the Access records; and use a new timestamp when you update and insert. You can't "delete" initially; you'll need to add a "delete" flag (and timestamp) so you can export "deleted" records; and purge / archive them later. You...
19 Mar 2024 by Pete O'Hanlon
Without knowing where you were sourcing your data, this is an almost impossible question to answer. There are a few things that do occur from looking at this. You are adding a random UUID but that could easily be auto-generated by the database....
31 Mar 2024 by GabrieleTronchin
A simple implementation of MartenDB. MartenDB is a .NET Transactional Document DB and Event Store on PostgreSQL. For more information about MartenDB
N 11 Apr 2024 by Pete O'Hanlon
Is there any link between these two tables? This is known as a relationship. An example of this might be something like: I build electric guitars so I have a table that contains a list of all the guitars. Each guitar has pickups, so I have a...