Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find current database type

Tags:

sql

We have a single SQL script for execution on multiple types of database. Is it possible to get the type of current database on which SQL script is executing?

Note: We can't use non standard SQL i.e . TSQL etc.

like image 225
Gaurav Avatar asked Mar 15 '11 07:03

Gaurav


People also ask

How do I know my database type?

One way to get the name of the underlying database you have connected with is by invoking the getDatabaseProductName() method of the DatabaseMetaData interface. This method returns the name of the underlying database in String format.

How do I know the type of database in SQL?

Even though there are no SQL queries that tell you the database type, there are queries which only work in certain database types and not in others. For example, SELECT version() will tell you the version of the current database if your database is PostgreSQL but it will cause error if you try to run it in Microsoft.


1 Answers

No, there is nothing in ANSI SQL about determining the database vendor.

like image 78
zerkms Avatar answered Sep 28 '22 14:09

zerkms