Creating your first table in SAP HANA and fetching data
There are a number of resourcs available online to setup SAP HANA on Amazon AWS and start developing on it. However, like in every other technology, there are some nuances in SAP HANA which the developer/user has to take care of before the “Hello World” program works. Overall, the installation, setup and initial usage of SAP HANA has been fairly smooth for me.
I followed the blogs/reference guides available on SAP SCN to setup SAP HANA developer instance on Amazon AWS. Then I installed SAP HANA Studio and SAP HANA client. My goal was to create a table with my csv data and run a select query on the table.
To achieve this goal, I had to do 3 things:
- Create a schema in my SAP HANA server/instance. The syntax for this is fairly simple as mentioned in SAP Help. Remember to use ‘owned by’ fragment in your SQL else schema may not appear in your HANA server catalog tree. To run the SQL, you can open SQL Editor with right click on your SAP HANA instance name in the Navigator
- Now I navigated to Quick Launch tab and clicked on ‘Import’ button in the Content section. This opened a wizard using which I imported my csv data. SAP HANA automatically creates the table as you’d expect. Few things you need to care about: a) If you don’t have any column which can be used as primary key, choose row store option and b) If you have header row in CSV, select aproriate options and c) Don’t give space in column names and 4) Carefully check the data types proposed by SAP HANA wizard.
- Now you are ready to fire your select statement in SQL Editor! Here is a trick. If you simply write select * from yourschema.yourtable, it won’t work. Rather the correct syntax is like this ‘select * from “yourschema”.”yourtable”. Of course, it always helps to refresh SAP HANA server catalog tree so that you can make sure your schema and table have been properly creeated.
Enjoy your SAP HANA journey!