Professional Documents
Culture Documents
Author(s):
Thorsten Fg
Topic:
SAP HANA
Published:
December 2012
Insert new tables in SAP HANA and fill them with data
1. Go to your schema. This is named like your SAP HANA system name.
Right-click on your schema and select SQL editor. Now you can insert the following code:
Note: Take your schema name instead of <YOUR SCHEMA> in the SQL syntax!
Table: ITIM_DIM
create column table "<YOUR SCHEMA>"."ITEM_DIM"(
"ITEM_ID" INTEGER null,
"ITEM_NAME" VARCHAR (100) null default '');
insert into "<YOUR SCHEMA>"."ITEM_DIM" values(1,'Shirts');
insert into "<YOUR SCHEMA>"."ITEM_DIM" values(2,'Jackets');
insert into "<YOUR SCHEMA>"."ITEM_DIM" values(3,'Trousers');
insert into "<YOUR SCHEMA>"."ITEM_DIM" values(4,'Skirts');
insert into "<YOUR SCHEMA>"."ITEM_DIM" values(5,'Purse');
Table: REGION_DIM
create column table "<YOUR SCHEMA>"."REGION_DIM"(
"REGION_ID" INTEGER null,
"REGION_NAME" VARCHAR (100) null default '',
"SUB_REGION_NAME" VARCHAR (100) null default '');
insert into "<YOUR SCHEMA>"."REGION_DIM" values(1,'Americas','NA');
insert into "<YOUR SCHEMA>"."REGION_DIM" values(2,'Americas','SA');
insert into "<YOUR SCHEMA>"."REGION_DIM" values(3,'APJ','Asia');
insert into "<YOUR SCHEMA>"."REGION_DIM" values(4,'APJ','Japan');
insert into "<YOUR SCHEMA>"."REGION_DIM" values(5,'EMEA','EMEA');
Table: SALES_FACT
create column table "<YOUR SCHEMA>"."SALES_FACT"(
"REGION_ID" INTEGER null,
"ITEM_ID" INTEGER null,
"SALES_AMOUNT" DOUBLE null);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(1,1,100);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(1,2,90);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(1,5,85);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(2,2,80);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(2,1,75);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(3,3,85);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(4,4,75);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(5,1,65);
insert into "<YOUR SCHEMA>"."SALES_FACT" values(5,2,65);
At the end of this section, you should have three tables:
If there are no tables, try right-clicking on your schema and refreshing.
Now you can define the attributes and key attributes you want to see later in the analyses. Right-click on the attributes
and choose Add as key attribute or Add as attribute.
In our case, the REGION_ID is added as the key attribute and the fields REGION_NAME and SUB_REGION_NAME are
added as attributes.
At the end, save and activate the attribute view. You can do this using the context menu by right-clicking on your
attribute view or using the status bar at the top of the output frame.
Please take note of the status massage in the job log frame at the bottom if there are any problems during activation.
Now we want to create an analytic view before the second attribute view.
After that, select your schema and the table SALES_FACT. Click Finish.
In the data foundation tab, select REGION_ID as Add as attribute and the field SALES_AMOUNT as Add as measure.
After you saved the view, you can switch to the logic view tab. Now put the attribute view ATTR_REGION into the
window using the drag-and-drop feature. Afterwards, connect the key fields REGION_ID with a n..1 referential join.
Finally, save and activate the view, as you did before with the attribute view.
At the end, save and activate the attribute view. You can do this using the context menu by right-clicking your attribute
view or using the status bar at the top of the output frame, if everything was correctly activated.
Go back to your analytic view. At this point, you must switch to the data foundation tab first. Here, select the field
ITEM_ID as Add as attribute and save your view. Then switch back to the logical view and drag your attribute view
ATR_ITEM into the window. Afterwards, join the fields ITEM_ID of both views, also with an n..1 referential join, as you
did before.
Save and activate the analytic view and take a look at the preview data again.
References
Part of this tutorial is based on the following source: http://www.youtube.com/watch?v=9hM83qw9tYs