In this article we will learn - How to define a design-time schema and maintain the schema definition in the repository.
SAP HANA XS enables you to create database schema as a design-time files in the repository. This is achieved with the help .hdbschema file.
For example a file MySchema.hdbschema will create a database schema MY_SCHEMA when activated.
Now let us see the steps to create a schema using hdbschema file in details.
Steps to create a schema using hdbschema file:
- Create a XS project as mentioned in the article Create Your First HANA XS Application using HANA Studio
- Right click and select New à Other à SAP HANA à Database Development à Schema.
- Specify file name as “MySchema”.
- Copy the below code and paste it in the file.
schema_name = "MY_SCHEMA";
- Right click and select Team à Activate. This will activate the file.
- Check in Catalog that the schema “MY_SCHEMA” is created.
Done!! You have successfully created schema using hdbschema file.
The Schema “MY_SCHEMA” is not visible in Catalog. What’s went wrong?
If you open the Catalog, you may not see the schema “MY_SCHEMA” created via hdbschema file.
After activation in the repository, the schema object is only visible in the catalog to the _SYS_REPO user. To enable other users, for example the schema owner, to view the newly created schema, you must grant the user the required SELECT privilege.
Grant SELECT privileges on the new schema to you user:
To get access to the Schema, open SQL Console and call below procedure:
'select, create any, insert, delete, update, execute, alter, drop',
<SCHEMA_NAME> is the name of the newly activated schema, and <USER_NAME> is the database user you want to give access to.