一、 Oracle
-- 查询版本
select to_number(REPLACE(substr(version,1,4),'.','')) AS version_number from v$instance;
-- 查询是否容器
select decode(cdb,'YES',1,0) IS_PLUGGABLE from v$database;
二、Mysql
select version() version;
三、DB2
select cast(substr(SERVICE_LEVEL,instr(SERVICE_LEVEL,'v')+1,instr(SERVICE_LEVEL,'.',1,1)-instr(SERVICE_LEVEL,'v')-1)*1000000+
substr(SERVICE_LEVEL,instr(SERVICE_LEVEL,'.',1,1)+1,instr(SERVICE_LEVEL,'.',1,2)-instr(SERVICE_LEVEL,'.',1,1)-1)*10000 +
substr(SERVICE_LEVEL,instr(SERVICE_LEVEL,'.',1,2)+1,instr(SERVICE_LEVEL,'.',1,3)-instr(SERVICE_LEVEL,'.',1,2)-1)*100 +
substr(SERVICE_LEVEL,instr(SERVICE_LEVEL,'.',1,3)+1,length(SERVICE_LEVEL)-instr(SERVICE_LEVEL,'.',1,3))*1 as bigint) as VERSION_NUMBER
from SYSIBMADM.ENV_INST_INFO;
四、SqlServer
SELECT cast(SUBSTRING(cast(SERVERPROPERTY('ProductVersion') as nvarchar), 0, PATINDEX('%.%', cast(SERVERPROPERTY('ProductVersion') as nvarchar))) as int) PRODUCTVERSION;