Create encrypted permanent tables over TDS
A SQL Server client can create an encrypted permanent table on Mimus with an ordinary CREATE TABLE. The DBA supplies the key and the creation default. Applications then use their usual INSERT, UPDATE and SELECT. A migration can also select encryption for a single transaction. This guide covers the 19.0.1 candidate with the four accepted changes, tested over TDS 7.4 on Debian 13 x86-64 image a3b80a5a99a1. Identify the build and patches
Prepare the key in the physical database
Start with an initialized Babelfish instance. The PG administrator uses psql to connect to physical database mimus on port 5432. The TDS client connects to logical database vault on port 1433. The example assumes deployment login lab_deploy maps to a user with permission to create tables in vault. Preload pg_tde and babelfishpg_tds, and install the pg_tde extension in public in the physical database. Instance initialization · Login and schema mapping
For a new test database, run the following on PG. First create /var/lib/mimus-keys outside PGDATA on the server, owned by the database service account with mode 0700. A database with a principal key already configured can use its existing key. Both the production and recovery systems need access to the same keys. Key providers and recovery
Create encrypted tables by default with ordinary T-SQL
If the application uses temporary tables, the PG administrator can give runtime connections the heap default and require encryption on the deployment login with tde_heap. These settings take effect on new physical connections. Recycle the affected connections in any pool.
Reconnect to vault as lab_deploy and send the following TDS batch. The first query shows the logical database and the login’s effective default. An application login granted DML privileges on the resulting table can read and write it with its own default set to heap.
Expect vault, tde_heap and a final value of paid. To require every application table to go through encrypted deployment, reserve permanent DDL privileges for the deployment login and grant the runtime login only the DML privileges it needs. A login with permission to create tables can override the AM default when enforcement is off.
For a physical database dedicated to encrypted tables, the PG administrator can apply both settings at database scope. New tables default to encryption and requests for heap are rejected. The settings apply across the logical databases mapped into that physical database. Existing plaintext tables require a separate rewrite. Use the mixed configuration above for connections that need T-SQL temporary objects. Convert an existing table · Settings for temporary objects
Select one table in a mixed database
On a deployment connection with default heap and enforcement off, create dbo.chosen in a dedicated transaction. Turn implicit transactions off, finish any open transaction, and send the complete script as one TDS batch. The same file is installed in the image at /usr/mimus-19/share/mimus/examples/tds-encrypted-table.sql. Download the tested deployment script
After BEGIN TRANSACTION, the script calls this PostgreSQL configuration function over TDS. The 'true' argument limits the setting to the transaction. Other tables created in that transaction inherit the same setting. Commit or rollback restores the connection’s previous default.
The script locates the table through sys.tables and sys.schemas. It commits once the table, primary-key index, unique index, TOAST table and TOAST index are all present and encrypted. An open transaction or implicit transactions turned on yields error 50000 at entry, leaving the caller in control of its transaction. A missing or plaintext member rolls back the deployment with error 51001. Adapt both the table name and the expected indexes when using the script for another schema.
Verify the physical storage from PG
After deployment, run this query as the PG administrator in mimus. In the example’s single-db mapping, vault.dbo maps to PG schema dbo. Substitute dbo.invoice for dbo.chosen to check the role-default example. For another mapping, look up the physical schema first. Look up a schema
Both sample tables should return five rows, all with encrypted true. The table and TOAST table use tde_heap. The three indexes use btree. During acceptance a 32,018-byte varchar(max) value in dbo.chosen occupied 17 TOAST chunks. After a restart, a new TDS connection read the same digest and committed an update visible to the next connection.
Migrate SQL Server TDE scripts
SQL Server protects its database encryption key (DEK) with a certificate or asymmetric key and enables TDE with ALTER DATABASE … SET ENCRYPTION ON. On Mimus, manage the provider and principal key through PG, check each physical relation, and configure WAL encryption separately. A TDS CREATE TABLE with WITH (ENCRYPTION=ON) or OFF fails before creating the table. SQL Server certificate and DEK commands and sys.dm_database_encryption_keys cannot manage or verify pg_tde storage. Microsoft’s TDE reference · WAL encryption on Mimus