Thursday, August 25, 2022

SQL test query or validation query

 

Ref: https://stackoverflow.com/questions/3668506/efficient-sql-test-query-or-validation-query-that-will-work-across-all-or-most

Many database connection pooling libraries provide the ability to test their SQL connections for idleness. For example, the JDBC pooling library c3p0 has a property called preferredTestQuery, which gets executed on the connection at configured intervals. Similarly, Apache Commons DBCP has validationQuery.

-- Access

SELECT 1 FROM (SELECT count(*) dual FROM MSysResources) AS dual


-- BigQuery, CockroachDB, Exasol, H2, Ignite, MariaDB, MySQL, PostgreSQL, 

-- Redshift, Snowflake, SQLite, SQL Server, Sybase ASE, Vertica

SELECT 1


-- MemSQL, Oracle

SELECT 1 FROM DUAL


-- CUBRID

SELECT 1 FROM db_root


-- Db2

SELECT 1 FROM SYSIBM.DUAL


-- Derby

SELECT 1 FROM SYSIBM.SYSDUMMY1


-- Firebird

SELECT 1 FROM RDB$DATABASE


-- HANA, Sybase SQL Anywhere

SELECT 1 FROM SYS.DUMMY


-- HSQLDB

SELECT 1 FROM (VALUES(1)) AS dual(dual)


-- Informix

SELECT 1 FROM (SELECT 1 AS dual FROM systables WHERE (tabid = 1)) AS dual


-- Ingres, Teradata

SELECT 1 FROM (SELECT 1 AS "dual") AS "dual"


No comments:

Post a Comment

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...