TIL you can mix ASC, DESC in ORDER BY (SQLite)

TL;DR: You can use ORDER BY column1 DESC, column2 ASC ... in your code. The other day I was trying to get a custom ordering in a list for an object: order decreasing by UNREAD MESSAGES count and then order ascending by DATE Initially, I tried a GROUP BY, but I could not get it to do the ordering properly. Then I […]

Add Primary Key Column to PostgreSQL Table

The other day I got a question: How to add a numeric PK column to an already existent table? A quick look on the net showed that it is indeed possible to add an auto-incrementing PK to an already existing table (if you don’t have already a PK that is!). The code is quite simple […]

Postgres: Show Schema Sizes in a Database

While loading a large database from files to a Postgres schema, I found very useful to know how much space on disk it actually occupies (just in case I need to re-size the disk). I found this answer online:

Which results in a list like: HTH, PS: All credit goes to this StackOverflow answer! […]

PostgreSQL: Call a Stored Procedure for Every Row

I guess that newbies in PostgreSQL like me have first question when they create a store procedure: How do I call it? The answer is simple; you just execute

. Then, usually immediately the second question pops up: I wrote a procedure which I need to call for each row in a table. How do […]

UPSERT (update or insert) in Oracle with Python

One of the things I had to do is to build a script to upload data (e.g. the content of a list of files) into a database with a single table. My table has 3 columns: ID – a 20-character string identifier with PK properties (unique) ARTICLE– an XMLType element with the article details CITEDBY […]

Memory dump: Work with XMLField in Oracle (part 4)

Table of Contents Part 1 – Prerequisites Part 2 – Create a table and perform a SELECT Part 3 – User Python to insert data Part 4 – references References for the series Using XQuery with Oracle XML DB XMLTYPE Oracle XML DB Developer’s Guide ORA-01461: can bind a LONG value only for insert into […]

Memory dump: Work with XMLField in Oracle (part 2)

TL;DR: Here I present a SQL example from creating the table to performing a SELECT. Table of Contents Part 1 – Prerequisites Part 2 – Create a table and perform a SELECT Part 3 – User Python to insert data Part 4 – references Table and XMLTYPE Once we’ve seen that we have XMLTYPE available, […]

Scroll to top