Check HANA edition with SQL? - hana

I have a JDBC connection to a SAP HANA database and I want to query whether it's a SAP HANA Cloud db or not. I know I can find the version with:
SELECT VERSION FROM SYS.M_DATABASE;
and this gives me 4.00.000.00.1608802791 for the cloud and 2.xx for my on-premise Dockerised version, but to avoid hard-coding version numbers everywhere, is there an equivalent query to, say, SQL Server's SELECT SERVERPROPERTY('edition')?

You could use SELECT VALUE FROM M_HOST_INFORMATION WHERE KEY='build_branch'
On premise: fa/hana2sp05
In the cloud: fa/CE2020.36
You might also like M_SYSTEM_OVERVIEW, it has interestign informations such as the server start time.

Related

view equivalent to dba_credentials in Oracle 11g

I am trying to create a Database check for all versions of oracle(11g,12c,19c) to check the credentials set on a user using dba_credentials.(something like a metric extension)
But dba_credentials is only available in Oracle 12c.
Is there any view in 11g i can use for this purpose using a 'case' in sql depending on the version?
Credentials as a separate type of object didn't exist in 11g. You set credentials as part of the dbms_scheduler package. If you want to view those credentials, you can query the dba_scheduler_credentials data dictionary table. Depending on what you're actually trying to accomplish, you may need to query that table in later versions as well since not everyone migrating to 12c will have switched over to the new way of managing credentials.

How can I reset the oracle JDBC?

I started to learn Java a month ago.
Today I was studying some SQL phrases which are necessary for creating websites using JSP and Servlets.
I used SQL Developer and JDBC.
After doing some insert/delete/update manipulation, I accidentally clicked on 'commit' instead of 'roll back'.
So some of my data in certain tables are lost and so am I...
I think I must delete and re-install JDBC to have all the basic data that Oracle offers.
But I'd like to ask for some help here before doing that, if there is any simpler way.
Can anyone help me please?
Thank you in advance.
I am not sure if it will help but here is the SQL I used:
INSERT INTO DEPARTMENTS VALUES(280, 'DataAnalytics', null, 1700);
INSERT INTO DEPARTMENTS (DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID,
LOCATION_ID) VALUES(280, 'DataAnalytics', null, 1700);
UPDATE emps SET SALARY=30000WHEREEMPLOYEE_ID=101;
UPDATE EMPS SET (JOB_ID, SALARY, MANAGER_ID)= (SELECT JOB_ID, SALARY,
MANAGER_ID FROM EMPS WHERE EMPLOYEE_ID=108) WHERE EMPLOYEE_ID=109;
DELETE FROM EMPS WHERE EMPLOYEE_ID=108; DELETE FROM EMPLOYEES WHERE
EMPLOYEE_ID=103;
I think you may be confusing JDBC with SQL. JDBC is short for Java Database Connectivity, and it's a Java standard used to connect from Java to relational databases (See Oracle's documentation on JDBC here: https://docs.oracle.com/en/database/oracle/oracle-database/18/jjdbc/introducing-JDBC.html#GUID-864DB502-5E50-4044-8132-33D6AAF8927A). Depending on what version of the Oracle Database you're running, the JDBC driver version, and which client you're using, you may find that you are missing some functionality, but that functionality is probably completely separate from the SQL you ran.
When you use SQL Developer to connect, you may be using a JDBC connection, but in all likelihood, you are using either a Basic or TNS Connection Type. Those do not rely on JDBC. The SQL you ran from SQL Developer modified the data because that's what SQL is used for. SQL is short for Structured Query Language, and it's widely used to manage data in relational databases.
By using SQL Developer, you should have access to all of the standard functionality that Oracle has to offer. You may be missing some features, but that is completely normal if you or your organization does not have a licensing agreement with Oracle and have not configured those features. Reinstalling JDBC won't change that.
What are you trying to accomplish? If you want to restore your data, JDBC has nothing to do with that. You will have to either: 1. Flashback the database or table (depending on which version of Oracle you're running,) which will restore the database (or the relevant object(s)) back to a specific point in time before you executed those SQL commands. 2. Use OEM or RMAN to restore the database to a time before you executed those SQL commands, or 3. Delete the relevant data and re-create (or re-import) your data.
Since you committed the transaction to manipulate that data, these are likely going to be your only options to restore the database how it was. If you know the original values that belong in those tables, I suppose that you could also write up more SQL to change the values back to the original. This may result in your desired outcome, but be forewarned that this method (and option #3) would not be considered a restore, and all of the changes that you made up to that point would still be apart of the transaction history. If that doesn't matter, that may be the easiest route for you to pursue.

Hana Column Store dialect to Oracle 12c SQL

While trying to benchmark Oracle's Database Inmemory, we were looking for publicly available benchmarking data set and tools. The CH-benCHmark suited our requirement exactly, but it has HANA Column Store Dialect as part of the source files.
So, our requirement is to convert these HANA Column Store dialect SQLs to Oracle 12c SQLs. Google search returned the conversion from Oracle to Hana dialect not the reverse.
Has anyone came across this requirement? Is there a simple/direct way to do the conversion?
Any pointers will be much helpful.
Yes I have done this exercise! there's no direct way from HANA Dialect to Oracle Dialect, But you can make use of ORACLE_LOADER and it's semantics to effectively create Oracle Dialect! Only problem you may face would be the flow, where HANA's flow is totally different from Oracle's schema creation flow.
For example:
you can easily use LOAD FROM FILE... syntax in HANA, But you need an externally organized table in case of Oracle.

Sql: export database using TSQL

I have database connection to database DB1. The only thing I could do - execute any t-sql statements including using stored procedures. I want to export the specific table (or even the specific rows of specific table) to my local database. As you can read abve, DBs are on diffrent servers meaning no direct connection is possible. Therefore question: Is it possible to write query that returns the other query to execute on local server and get data? Also note, that table contains BLOBs. Thanks.
If you have SQL Server Management Studio, you can use the data import function on your local database to get the data. It works as long as you have Read/Select access on the tables you are trying to copy.
If you have Visual Studio you can use the database tools in there to move data between two servers as long as you can connect to both from your workstation.
Needs Ultimate or Premium though:
http://msdn.microsoft.com/en-us/library/dd193261.aspx
RedGate has some usefull tools too:
http://www.red-gate.com/products/sql-development/sql-compare/features
Maybe you should ask at https://dba.stackexchange.com/ instead.
If you can login to the remote db (where you can only issue t-sql), you may create linked server on your local server to the remote and use it later directly in queries, like:
select * from [LinkedServerName].[DatabaseName].[SchemaName].[TableName]

How can I post updates (commits) in oracle db to SQL Server 2005

We have an application (BaaN) on Oracle Database.
We also have an application that is on SQL Server 2005 which uses Oracle (BaaN) contents.
Currently we cache all contents of the Oracle DB to SQL Server nightly through linked server from SQL Server to Oracle.
Thought of using a trigger on Oracle db tables to write contents to Oracle table (DeltaCommits) as the commits occur, and then periodically look for entries in DeltaCommits from SQL Server using a scheduled job.
Or can you please suggest a better way to accomplish this ..
Thanks
It's possible to use replication to transfer data between Oracle and SQL server.
This guide looks like a useful starting point which may help you to decide whether this is a route you want to consider.