cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a table in sql so that it goes into desired schema?

0 Kudos

Hi,

While creating a table in sql editor sap hana studio what is the syntax so that the table is created in desired schema using sql.

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

The default schema for your session is the schema that has the same name as your user.

For example, your user is called "SAPDEV" and it's default schema is also called "SAPDEV".

As users can own multiple schemas, you can switch with the "SET SCHEMA <schema_name>" command (https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.00/en-us/20fd550375191014b886a338afb4cd5f.html).

0 Kudos

Hi,

I have followed the above steps and was able to create table but when trying to insert values into the table its not reflecting, please help.

Answers (1)

Answers (1)

luisdarui
Active Contributor
0 Kudos

Hi Rohit,

You simply have to logon with the database user that OWNS the schema you want.

Example:

If your SCHEMA is SAPSR3, you have to logon with SAPSR3 user, then simply create the table.

lbreddemann
Active Contributor
0 Kudos

That only works for the default schema of any user and requires more access privileges than necessary (not just creating objects in another schema, but actually impersonating a user). Your answer would be true for DBMS that don't properly support schema, e.g. ORACLE.

Former Member
0 Kudos

Hi lars,

When i m trying to retrive the tables present in the schema im able to retrieve even the system tables.

My requirement is I need to retrieve only the tables present in the schema but not the system tables(dafault tables).

Note: I want a solution such that we should not pass schema name in the SQL Query