I am searching for a SELECT
query that works in both SQL Server and Oracle. It does not matter what it selects or what the result is, but it cannot depend on the database contents.
This sounds like a simple thing to do, but I cannot come up with an example.
First I thought of SELECT 0
, but Oracle needs FROM dual
which SQL Server does not support. Then I tried SELECT * FROM INFORMATION_SCHEMA.TABLES
, but Oracle does not have those...
Edit: this question arose trying to check whether some SQL Server linked servers are reachable. But I think it is very interesting by itself.
Oracle, meanwhile, uses PL/SQL, or Procedural Language/SQL. Both are different “flavors” or dialects of SQL and both languages have different syntax and capabilities. The main difference between the two languages is how they handle variables, stored procedures, and built-in functions.
You get access to data stored in Oracle right from the SQL server without the need for coding. You can perform different actions on data stored in Oracle from SQL Server, such as distributed queries. You can address data stored in Oracle the same way you would SQL Server.
Oracle is owned by Oracle Corporation and can run on a wide variety of platforms such as Windows, Linux, Solaris, HP-UX, and OS-X. Oracle supports PL/SQL and SQL language to write queries to access data from its database. SQL Server is owned by Microsoft and can only be used on the Windows platform.
MySQL and Oracle SQL are both RDBMSs (relational database management systems) owned by Oracle Corporation. MySQL is built to be primarily free and open-source, while Oracle is primarily built to be commercial and paid. MySQL is also more customizable than Oracle which is because Oracle is a finished product.
On rextester, the following works for both SQL Server and Oracle:
select count(*)
from sys.all_objects;
There may be a handful of other sys tables that this would work for.
EDIT:
I'm going to echo Jeroen's comment. If you want the same result as well, then add a clause that filters out all rows:
select count(*) as always_zero
from sys.all_objects
where 1 = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With