Development schema, production schema

Most of us separate development data from production data, physically or at least, logically (except maybe Chuck Norris (official website, no kidding!)). If you’re lucky and you can afford multiple Oracle / other-expensive-database licenses, you might clone the same schema / owner name for every application instance on different servers. But sometimes, you can’t do that, and you have to put all schemata in the same box and name them:

DB_DEV

DB_TEST

DB_PROD

Or worse… several productive instances in the same box

Another, similar use case is when you deploy several instances of the same application in the same environment. For instance, you have a blogging server with 10 users. Every user has their own independent blog with their own tables. You may either resolve this problem by creating multiple schemata / owners again:

DB_USER1

DB_USER2

DB_USER3

Or, by adding prefixes / suffixes to your tables within a single schema:

DB.USER1_POSTS

DB.USER1_COMMENTS

DB.USER2_POSTS

DB.USER2_COMMENTS

This means that in every executed SQL statement, you’d have to patch relevant environments (DEV, TEST, PROD) or users (USER1, USER2, USER3) into all of your database artefacts. There are a lot of things that can go wrong.

Let jOOQ do that for you, instead

With jOOQ, it’s simple. jOOQ always generates the schema / owner in the generated SQL statements. This is usually the name of your development schema from which you generated source code. So if you have select from a DB_DEV.POSTS table, you’ll do this: