Skip to Content
0

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

May 30, 2017 at 02:34 PM

218

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Lars Breddemann
Jun 01, 2017 at 12:37 AM
0

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 " command ( https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.00/en-us/20fd550375191014b886a338afb4cd5f.html).

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Luis Darui
May 31, 2017 at 11:52 PM
-1

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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.

0

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

0