Archive for the ‘PostgreSQL’ Category
Posted by jpluimers on 2019/08/29
Via [WayBack] SQL select only rows with max value on a column, I bumped into http://sqlfiddle.com/#!9/a6c585/1:
Application for testing and sharing SQL queries.
Source: [WayBack] SQL Fiddle | A tool for easy online testing and sharing of database problems and their solutions.
It is a cool site, currently supporting these SQL back-ends:
- MySQL 5.6
- Oracle 11g R2
- PostgreSQL 9.6
- PostgreSQL 9.3
- SQLite (WebSQL)
- SQLite (SQL.js)
- MS SQL Server 2014
You can host it yourself using [WayBack] GitHub – zzzprojects/sqlfiddle2: New version of SQL Fiddle based on OpenIDM (in the past it was [WayBack] GitHub – zzzprojects/sqlfiddle)
Other resources for learning and playing around with SQL:
–jeroen
Posted in Database Development, Development, MySQL, OracleDB, PostgreSQL, Software Development, SQL, SQL Server | Leave a Comment »
Posted by jpluimers on 2018/06/26
I need to write up some notes, but there are some links that will help me:
It’s a question of readability. There is no difference in performance.
Old versions of SQL Server were silly enough to look up meta data, but not any more.
SELECT foo FROM bar WHERE EXISTS (SELECT * FROM baz WHERE baz.id = bar.id);
SELECT foo FROM bar WHERE EXISTS (SELECT 1 FROM baz WHERE baz.id = bar.id);
I am not considering NULL or “fun variants” which don’t seem intuitive to me.
SELECT foo FROM bar WHERE EXISTS (SELECT NULL FROM baz WHERE baz.id = bar.id);
SELECT foo FROM bar WHERE EXISTS (SELECT 1/0 FROM baz WHERE baz.id = bar.id);
The question popped up in comments just now. I researched the manuals of the most popular RDBMS:
A search on SO for code:"EXISTS (SELECT 1" yields 5,048 results.
A search on SO for code:"EXISTS (SELECT *" yields 5,154 results.
Updated links and counts 07.2015.
So SELECT * has the popular vote and the big commercial RDBMS on its side.
I find SELECT 1 more intuitive. It’s like saying “if at least one exists”.
Is SELECT * more intuitive?
–jeroen
Posted in Database Development, Development, Firebird, InterBase, MySQL, PostgreSQL, SQL, SQL Server | Leave a Comment »
Posted by jpluimers on 2017/11/30
Interesting: https://github.com/MinBZK/OperatieBRP
[WayBack] The Netherlands saw a big I.T. project meant to deliver a new citizen registry system fail. So they did one thing right. All the source code is now on github… – Jan Wildeboer – Google+
It includes both documentation and source code.
A bit of browsing reveals at least some of the technologies used:
Most of the SQL code seems to be generated.
There are truckloads of .XML configuration files, typical for a Java environment. Some configuration is in .properties files.
–jeroen
Posted in ActiveMQ, Development, Java, Java Platform, MQ Message Queueing/Queuing, Open Source, PostgreSQL, Software Development | Leave a Comment »
Posted by jpluimers on 2017/08/02
I thought I posted a reference to this a long time ago, but didn’t.
It’s one of the things I show when explaining joins to people. Sometimes I need it myself too (:
The article explains these in greater detail:
- INNER JOIN
- LEFT JOIN
- RIGHT JOIN
- OUTER JOIN
- LEFT JOIN EXCLUDING INNER JOIN
- RIGHT JOIN EXCLUDING INNER JOIN
- OUTER JOIN EXCLUDING INNER JOIN
Note:
- the opposite of INNER JOIN is not OUTER JOIN. It’s OUTERJOIN EXCLUDING INNER JOIN
- the opposite of OUTER JOIN is empty set.
But the diagram is usually speaks for itself.
–jeroen
Source: Visual Representation of SQL Joins – CodeProject
Read the rest of this entry »
Posted in Access, Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, SQL, SQL Server | Leave a Comment »
Posted by jpluimers on 2014/04/08
Posted in Access, Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »
Posted by jpluimers on 2014/01/22
A while ago, I came across an interesting post Bad Habits to Kick : Using AS instead of = for column aliases by Aaron Bertrand, a major contributor on SQLblog.com – The SQL Server blog spot on the web.
The last link indicates my problem with this “AS” versus “=”: it is SQL Server specific.
So, if you mainly use SQL Server, then it is OK (or even preferable) to use “=” for aliasing columns in human written SQL as it makes spotting the names used much easier. Read the rest of this entry »
Posted in Access, Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, Paradox, PostgreSQL, SQL, SQL Server, Sybase | Leave a Comment »
Posted by jpluimers on 2013/01/18
In most database index nodes are doubly linked to allow bi-directional scans. http://is.gd/8CMb7w, however not for InterBase and FireBird, there the reverse link isn’t used because it can be inconsistent due to write order of index pages.
The result is that in Firebird and InterBase, indexes are single-directional (either ascending or descending).
This is for your safety: it guarantees index consistency, even if because of EMP, your machine suddenly reboots after your tank fired a missile.
–jeroen
via Twitter / Avalanche1979: @SQLPerfTips For Firebird the ….
(Wow, did I really wrote 1200 blog posts?)
Posted in Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, Sybase | Leave a Comment »
Posted by jpluimers on 2012/09/26
Database Workbench is my tool of choice for doing database work: it supports many backends in a consistent manner, and behaves a lot like Delphi (like running and debugging stored procedures).
Yesterday the free Lite Editions of Version 4.3.1 got released:
Database Workbench 4.3.1 free Lite Editions released
This new release of Database Workbench brings new features and enhancements, as requested by our users.
The free Lite Editions are now available.
More information about Database Workbench is available at the Database Workbench page, download your copy today via our downloads page, pricing information is available, the limited Lite Editions are available for free.
Changes in this release
- The full details and list of changes are available here and here.
- New
- MySQL Stored Procedure, Function and Trigger Debugging (Pro Edition only)
- InterBase and Firebird syntax check in Trigger Editor (Pro Edition only)
- Incremental search of data in SQL, Table and View Editor
Changes
- More compact taskbar
- MySQL support for BINARY and VARBINARY datatypes
- MySQL error fixed when not having access to mysql.procs
- MySQL fix for fetching foreign key information
- Data Import and Export fixes
- Windows 7 event log error by SideBySide fixed
And much more…
–jeroen
via News @ Upscene Productions.

Posted in Database Development, Delphi, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 1 Comment »
Posted by jpluimers on 2012/08/21
Few people know about the INFORMATION_SCHEMA views that have been there since SQL-92.
Two funny things about that standard:
A few reasons I can imagine not many people know about the INFORMATION_SCHEMA:
- Not all relational database servers implement them, and of the ones that do implement them, not all versions implement all views.
That’s what this article is about; currently it lists only SQL Server 2000 and 2008 R2 (tried both) and PostgreSQL (verified docs), but I will update it as soon as I have run the script on other versions of SQL server and database vendors.
- It is hard to find the official ISO standards in a public way, and ISO itself sometimes puts things online, and at other times wants money for it
I remember the Y2K preparation era where the ISO-8601 standard was freely available at http://www.iso.ch/markete/8601.pdf, soon after the Year 2000, the PDF got locked behind a payment engine.
ISO suffers from heavy link rot too, for instance the ISO 3166 country codes used to be at http://www.iso.org/iso/prods-services/iso3166ma, but are now at http://www.iso.org/iso/home/standards/country_codes.htm. What about HTTP 303 or 302 redirect here guys?
Since SQL-92, the INFORMATION_SCHEMA (and its twin DEFINITION_SCHEMA) have been extended. The last extension in 2008. Together they allow SQL databases to be self-describing (I think no vendor has attained that) and the structures queryable in a standard way
In fact that is the main purpose: these views in INFORMATION_SCHEMA are a very convenient standard way to query – in a vendor agnostic way – about tables, views, columns, etc. Read the rest of this entry »
Posted in Database Development, Development, Firebird, InterBase, ISO 8601, MySQL, OracleDB, PostgreSQL, Power User, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, Sybase | Leave a Comment »