這篇文章主要介紹“怎么將csv包含的數(shù)據(jù)導(dǎo)入SAP Cloud Platform HANA MDC里”,在日常操作中,相信很多人在怎么將csv包含的數(shù)據(jù)導(dǎo)入SAP Cloud Platform HANA MDC里問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么將csv包含的數(shù)據(jù)導(dǎo)入SAP Cloud Platform HANA MDC里”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站設(shè)計、做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)和田,十余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
本文使用的csv文件
SAP HANA XS) enables you to create database schema, tables, views, and sequences as design-time files in the repository.
這個練習(xí)里,我們將會使用SAP HANA Extended Application Services (XS)提供的database schema,tables和views來實現(xiàn)數(shù)據(jù)導(dǎo)入的效果。
The HDBtable syntax is a collective term which includes the different configuration schema for each of the various design-time data artifacts, for example: schema (.hdbschema), sequence (.hdbsequence), table (.hdbtable), and view (.hdbview).
This is why we will be using the SAP HANA HDBtable syntax including Core Data Service (CDS) artifacts instead, which only requires the SAP HANA Web-based Development Workbench available with any SAP HANA MDC on the SAP Cloud Platform. All the objects will be created as design-time and will allow us to adapt the structure easily without reloading the data.
首先在SAP Cloud Platform Neo環(huán)境的HANA MDC實例里,打開HANA Web-based development workbench,切換到Catalog視圖:
點擊SQL,使用SQL語句創(chuàng)建一個新的user: MOVIELENS_USER
DROP USER MOVIELENS_USER CASCADE; CREATE USER MOVIELENS_USER PASSWORD Welcome18Welcome18 NO FORCE_FIRST_PASSWORD_CHANGE; ALTER USER MOVIELENS_USER DISABLE PASSWORD LIFETIME; call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.ide.roles::CatalogDeveloper' ,'MOVIELENS_USER'); call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.ide.roles::Developer' ,'MOVIELENS_USER'); call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.ide.roles::EditorDeveloper' ,'MOVIELENS_USER'); call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.xs.ide.roles::CatalogDeveloper' ,'MOVIELENS_USER'); call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.xs.ide.roles::Developer' ,'MOVIELENS_USER'); call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.hana.xs.ide.roles::EditorDeveloper' ,'MOVIELENS_USER'); GRANT EXECUTE on _SYS_REPO.GRANT_ACTIVATED_ROLE TO MOVIELENS_USER WITH GRANT OPTION; GRANT EXECUTE on _SYS_REPO.GRANT_SCHEMA_PRIVILEGE_ON_ACTIVATED_CONTENT TO MOVIELENS_USER WITH GRANT OPTION; GRANT EXECUTE on _SYS_REPO.GRANT_PRIVILEGE_ON_ACTIVATED_CONTENT TO MOVIELENS_USER WITH GRANT OPTION; GRANT EXECUTE on _SYS_REPO.REVOKE_ACTIVATED_ROLE TO MOVIELENS_USER WITH GRANT OPTION; GRANT EXECUTE on _SYS_REPO.REVOKE_SCHEMA_PRIVILEGE_ON_ACTIVATED_CONTENT TO MOVIELENS_USER WITH GRANT OPTION; GRANT EXECUTE on _SYS_REPO.REVOKE_PRIVILEGE_ON_ACTIVATED_CONTENT TO MOVIELENS_USER WITH GRANT OPTION; GRANT "CREATE SCHEMA" TO MOVIELENS_USER; GRANT REPO.READ on "public" TO MOVIELENS_USER; GRANT REPO.MAINTAIN_IMPORTED_PACKAGES on "public" TO MOVIELENS_USER; GRANT REPO.MAINTAIN_NATIVE_PACKAGES on "public" TO MOVIELENS_USER; GRANT REPO.EDIT_NATIVE_OBJECTS on "public" TO MOVIELENS_USER; GRANT REPO.EDIT_IMPORTED_OBJECTS on "public" TO MOVIELENS_USER; GRANT REPO.ACTIVATE_NATIVE_OBJECTS on "public" TO MOVIELENS_USER; GRANT REPO.ACTIVATE_IMPORTED_OBJECTS on "public" TO MOVIELENS_USER;
執(zhí)行后,該用戶創(chuàng)建成功:
注銷SYSTEM用戶,使用新創(chuàng)建的用戶登錄:
切換到Editor視圖:
在content節(jié)點下,右鍵菜單,新建一個Application:
Package維護(hù)成public.aa.movielens:
新建三個package,分別為data, hdb和service:
將之前鏈接里提供的csv文件導(dǎo)入data package內(nèi):
HANA schema是存放HANA數(shù)據(jù)庫對象諸如表,視圖,存儲過程等的容器。
新建一個.hdbschema文件,內(nèi)容如下:
再創(chuàng)建一個user.hdbrole文件:
內(nèi)容如下:
role public.aa.movielens.hdb::user extends catalog role "sap.pa.apl.base.roles::APL_EXECUTE", "AFLPM_CREATOR_ERASER_EXECUTE", "AFL__SYS_AFL_AFLPAL_EXECUTE" { schema public.aa.movielens.hdb:MOVIELENS.hdbschema: SELECT, EXECUTE, CREATE ANY; }
這個role定義了我們創(chuàng)建的這個應(yīng)用工作時需要的權(quán)限:
最后創(chuàng)建CDS artifacts:
新建一個data.hdbdd文件:
namespace public.aa.movielens.hdb; @Schema : 'MOVIELENS' context "data" { @Catalog.tableType : #COLUMN Entity LINKS { key MOVIEID : Integer; IMDBID : Integer; TMDBID : Integer; }; @Catalog.tableType : #COLUMN Entity MOVIES { key MOVIEID : Integer; TITLE : String(255); GENRES : String(255); }; @Catalog.tableType : #COLUMN Entity RATINGS { key USERID : Integer; key MOVIEID : Integer; RATING : hana.SMALLDECIMAL; TIMESTAMP : Integer; }; @Catalog.tableType : #COLUMN Entity TAGS { key USERID : Integer; key MOVIEID : Integer; key TAG : String(255); TIMESTAMP : Integer; }; };
使用下列的SQL語句將新創(chuàng)建的user role分配給用戶MOVIELENS_USER:
創(chuàng)建一個table-import配置文件,在里面指定存儲于csv文件里的數(shù)據(jù),按照怎樣的邏輯寫入HANA MDC的持久化對象,比如數(shù)據(jù)庫表里。
hdb package里創(chuàng)建一個新的文件data.hdbti :
import = [ { table = "public.aa.movielens.hdb::data.LINKS"; schema = "MOVIELENS" ; file = "public.aa.movielens.data:links.csv"; header = true; delimField = ","; delimEnclosing= "\""; }, { table = "public.aa.movielens.hdb::data.MOVIES"; schema = "MOVIELENS" ; file = "public.aa.movielens.data:movies.csv"; header = true; delimField = ","; delimEnclosing = "\""; }, { table = "public.aa.movielens.hdb::data.RATINGS"; schema = "MOVIELENS" ; file = "public.aa.movielens.data:ratings.csv"; header = true; delimField = ","; delimEnclosing= "\""; }, { table = "public.aa.movielens.hdb::data.TAGS"; schema = "MOVIELENS" ; file = "public.aa.movielens.data:tags.csv"; header = true; delimField = ","; delimEnclosing= "\""; } ];
此時執(zhí)行下列SQL語句,就可以成功從HANA MDC實例的數(shù)據(jù)庫表里讀取源自csv文件里的數(shù)據(jù)了:
select 'links' as "table name", count(1) as "row count" from "MOVIELENS"."public.aa.movielens.hdb::data.LINKS" union all select 'movies' as "table name", count(1) as "row count" from "MOVIELENS"."public.aa.movielens.hdb::data.MOVIES" union all select 'ratings' as "table name", count(1) as "row count" from "MOVIELENS"."public.aa.movielens.hdb::data.RATINGS" union all select 'tags' as "table name", count(1) as "row count" from "MOVIELENS"."public.aa.movielens.hdb::data.TAGS";
到此,關(guān)于“怎么將csv包含的數(shù)據(jù)導(dǎo)入SAP Cloud Platform HANA MDC里”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
網(wǎng)頁標(biāo)題:怎么將csv包含的數(shù)據(jù)導(dǎo)入SAPCloudPlatformHANAMDC里
本文來源:http://weahome.cn/article/jpipjc.html