How to update database table schemas with NHibernate schema generation?

The SchemaUpdate object provides database schema updating, by apparently generating and executing a series of SQL UPDATE statements (as well as constraint statements) when it’s void Execute(bool script, bool doUpdate) function is called. The SchemaUpdate class is in the NHibernate.Tool.hbm2ddl namespace, which can be found in the Nhibernate.dll file. SchemaUpdate is mentioned in chapter 15 … Read more

Json Schema example for oneOf objects

Try this: { “description” : “schema validating people and vehicles”, “type” : “object”, “oneOf” : [ { “type” : “object”, “properties” : { “firstName” : { “type” : “string” }, “lastName” : { “type” : “string” }, “sport” : { “type” : “string” } } }, { “type” : “object”, “properties” : { “vehicle” : … Read more

How to generate entire DDL of an Oracle schema (scriptable)?

You can spool the schema out to a file via SQL*Plus and dbms_metadata package. Then replace the schema name with another one via sed. This works for Oracle 10 and higher. sqlplus<<EOF set long 100000 set head off set echo off set pagesize 0 set verify off set feedback off spool schema.out select dbms_metadata.get_ddl(object_type, object_name, … Read more

PostgreSQL’s schemas for multi-tenant applications

Performance isn’t worse, necessarily. As the article explains, there are specific conditions which make the schema approach better or worse depending on your application design and workload. Let me explain the tradeoffs of the “tenant-schema” vs. “shared-table” approaches: tenant-schema is best when you have a relatively small number of fairly large tenants. An example of … Read more

Rename SQL Server Schema

If you have a large number of objects in a schema, you can use something like this to generate all the changes automatically (it only does tables and views, so before you run it, you might need to expand it to SPs, UDFs, etc.) USE SandBox DECLARE @OldSchema AS varchar(255) DECLARE @NewSchema AS varchar(255) DECLARE … Read more

Why psql can’t find relation name for existing table?

Postgres psql needs escaping for capital letters. Eonil=# \d+ “TestTable1” So this works well. Eonil=# \d+ “TestTable1” Table “public.TestTable1” Column | Type | Modifiers | Storage | Description ——–+——————+———–+———-+————- ID | bigint | not null | plain | name | text | | extended | price | double precision | | plain | Indexes: “TestTable1_pkey” … Read more