❗Always refer to the latest Babelfish and Aurora PostgreSQL documentation for the most accurate and detailed information.
These scripts typically help with configuration, diagnostics, and compatibility checks, making the migration and interoperability between SQL Server and Aurora PostgreSQL smoother. Here are some common and useful types of scripts:
- Version and Compatibility Checks
Scripts to check the version of Babelfish and ensure compatibility with SQL Server syntax.
SELECT SERVERPROPERTY('babelfishversion') AS BabelfishVersion, aurora_version() AS AuroraPostgreSQLVersion;
- Database Creation and Configuration
Scripts to create databases and configure them for use with Babelfish.
CREATE DATABASE myDatabase; EXECUTE sp_babelfish_configure 'myDatabase', 'enabled', 'true';
- Escape Hatches Configuration
Adjusting Babelfish escape hatches controls how certain SQL Server behaviors are handled.
EXECUTE sp_babelfish_configure 'escape_hatch_session_setting', 'ignore'; EXECUTE sp_babelfish_configure 'escape_hatch_storage_engine', 'ignore';
- Object Mapping Information
Scripts to check the mapping of SQL Server objects to PostgreSQL.
SELECT * FROM sys.babelfish_namespace_ext WHERE dbname = 'myDatabase';
- Monitoring and Diagnostics
Queries to monitor the performance and diagnose issues.
SELECT * FROM pg_stat_activity WHERE datname = 'myDatabase'; SELECT * FROM babelfishpg_tsql.sys_dm_exec_requests;
- Security and User Management
Managing users and permissions is especially important due to differences in security models between SQL Server and PostgreSQL.
CREATE USER myUser WITH PASSWORD 'myPassword'; GRANT ALL PRIVILEGES ON DATABASE myDatabase TO myUser;
- Data Import/Export
Scripts to facilitate data migration between SQL Server and Aurora PostgreSQL.
-- Exporting data from SQL Server BCP myDatabase.dbo.myTable OUT datafile.bcp -c -T -- Importing data into Aurora PostgreSQL COPY myTable FROM '/path/to/datafile.bcp';
- Routine Maintenance Tasks
Regular maintenance tasks like vacuuming, analyzing tables, or checking for index bloat.
VACUUM FULL VERBOSE ANALYZE myTable; SELECT * FROM pg_stat_user_indexes WHERE idx_tup_read > idx_tup_fetch;
- Transaction and Lock Management
Scripts to view and manage transactions and locks, particularly useful in troubleshooting performance issues.
SELECT * FROM pg_locks WHERE granted = false; SELECT * FROM babelfishpg_tsql.sys_dm_tran_active_transactions;
- Check the mapping between Babelfish and PostgreSQL
SELECT
pg.dbname AS babelfishDBName,
be.orig_name AS schemaname,
pg.nspname AS pgSchemaNameForDMS,
pg.oid,
SCHEMA_ID(be.orig_name) AS MapsToPGOID
FROM
sys.pg_namespace_ext AS pg
INNER JOIN
sys.babelfish_namespace_ext AS be
ON pg.nspname = be.nspname
WHERE
dbname = DB_NAME()
ORDER BY
schemaname;