How to check the connection to the database without the name of its tables

The point here is that I don’t have database table names , so please do not suggest choosing one table for this. SELECT COUNT (*) '

+3
source share
3 answers

It depends on the database, but usually there are some tables that always exist or a table is not even required.

For Oracle:

SELECT 1 FROM dual

For SqlServer:

SELECT 1

Not very elegant, but usually does the job if you know the brand of the database.

+5
source

, , - DbConnection.GetSchema, , , ... , "heartbeat", .

+1

You can run a command that does not query the table, for example:

select @@VERSION
+1
source

All Articles