Synonyms (SAP HANA): Unterschied zwischen den Versionen
Aus MattWiki
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
== | == How to Create Synonyms == | ||
This how to is based on a fictional existing schema "USER_DB" which contains a table "EMPLOYEES". | |||
CREATE SCHEMA USER_DB | |||
CREATE TABLE USER_DB.EMPLOYEES (id INT PRIMARY KEY, firstname VARCHAR(50), lastname VARCHAR(50)) | |||
=== Create User Provided Service in XSA Cockpit === | |||
'''USER_DB_UPS''' | |||
{ | |||
"schema": "USER_DB", | |||
"password": " < password >”, | |||
"driver": "com.sap.db.jdbc.Driver", | |||
"port": "30015", | |||
"host": "localhost", | |||
"user": " <user-db-schema-user> “, | |||
"tags": ["hana"] | |||
} | |||
Verify ''USER_DB_UPS'' in Database Explorer by adding it from HDI containers | |||
=== Add User Provided Service to mta.yaml === | |||
Add the user proviced service as a resource to the MTA project | |||
'''Create new resource "USER_DB_CROSS_SCHEMA_SERVICE"''' | |||
# '''Type:''' org.cloudfoundry.existing-service | |||
# '''Parameters:''' service-name = USER_DB_UPS | |||
# '''Properties:''' ups_name = ${service-name} | |||
'''Change DB module''' | |||
# '''Requires:''' USER_DB_CROSS_SCHEMA_SERVICE, group = SERVICE_REPLACEMENTS | |||
# '''Properties:''' | |||
## key = USER_DB_CROSS_SCHEMA_SERVICE | |||
## service = ~{ups_name} | |||
=== Assign Privileges === | |||
In order to assign the priviledges from the UPS to the object owner user of the HDI container create new file in <code>/db/cfg/user_db_schema.hdbgrants</code> | |||
{ | |||
"USER_DB_UPS": { | |||
"object_owner": { | |||
"schema_privileges": [{ | |||
"reference": "USER_DB", | |||
"privileges_with_grant_option": ["SELECT METADATA", "SELECT CDS METADATA", "SELECT"] | |||
}] | |||
}, | |||
"application_user": { | |||
"schema_privileges": [{ | |||
"reference": "USER_DB", | |||
"privileges_with_grant_option": ["SELECT METADATA", "SELECT CDS METADATA", "SELECT"] | |||
}] | |||
} | |||
} | |||
} | |||
=== Create Synonym === | |||
Create <code>/db/src/user_db.hdbsynonym</code> with following content: | |||
{ | |||
"user_db_employees": { | |||
"target": { | |||
"object": "EMPLOYEES", | |||
"schema": "USER_DB" | |||
} | |||
} | |||
} | |||
Test synonym i.e. with a Calculation View based on it. | |||
== Public Tutorials from SAP == | |||
# https://developers.sap.com/tutorials/xsa-create-user-provided-anonymous-service.html | |||
# https://developers.sap.com/tutorials/haas-dm-access-cross-container-schema.html | |||
[[Category:SAP]] | [[Category:SAP]] | ||
[[Category:HANA]] | [[Category:HANA]] |
Version vom 7. Juni 2021, 15:35 Uhr
How to Create Synonyms
This how to is based on a fictional existing schema "USER_DB" which contains a table "EMPLOYEES".
CREATE SCHEMA USER_DB CREATE TABLE USER_DB.EMPLOYEES (id INT PRIMARY KEY, firstname VARCHAR(50), lastname VARCHAR(50))
Create User Provided Service in XSA Cockpit
USER_DB_UPS
{ "schema": "USER_DB", "password": " < password >”, "driver": "com.sap.db.jdbc.Driver", "port": "30015", "host": "localhost", "user": " <user-db-schema-user> “, "tags": ["hana"] }
Verify USER_DB_UPS in Database Explorer by adding it from HDI containers
Add User Provided Service to mta.yaml
Add the user proviced service as a resource to the MTA project
Create new resource "USER_DB_CROSS_SCHEMA_SERVICE"
- Type: org.cloudfoundry.existing-service
- Parameters: service-name = USER_DB_UPS
- Properties: ups_name = ${service-name}
Change DB module
- Requires: USER_DB_CROSS_SCHEMA_SERVICE, group = SERVICE_REPLACEMENTS
- Properties:
- key = USER_DB_CROSS_SCHEMA_SERVICE
- service = ~{ups_name}
Assign Privileges
In order to assign the priviledges from the UPS to the object owner user of the HDI container create new file in /db/cfg/user_db_schema.hdbgrants
{ "USER_DB_UPS": { "object_owner": { "schema_privileges": [{ "reference": "USER_DB", "privileges_with_grant_option": ["SELECT METADATA", "SELECT CDS METADATA", "SELECT"]
}]
}, "application_user": { "schema_privileges": [{ "reference": "USER_DB", "privileges_with_grant_option": ["SELECT METADATA", "SELECT CDS METADATA", "SELECT"] }] } } }
Create Synonym
Create /db/src/user_db.hdbsynonym
with following content:
{ "user_db_employees": { "target": { "object": "EMPLOYEES", "schema": "USER_DB" } } }
Test synonym i.e. with a Calculation View based on it.