0

When I create a new SQL script , for example

select * from table

When I execute this the sql that gets ran is

SELECT * FROM MYNAME.TABLE

I understand DB2 does this , but I want the schema name to be concatenated onto the table names, not my username.

SELECT * FROM SCHEMANAME.TABLE

It did this for me before, but I dont know what changed that it now only puts the database username at the end of the tables.

Does anyone know how to set it so the schema name gets added on?

mustaccio
  • 18,234
  • 16
  • 48
  • 57
MrClamps
  • 31
  • 9
  • It's not clear what you're asking. Are you asking that the schema name be `added into` your script? Or do you want your script to _run against_ your desired schema when that schema name doesn't match your username? – user2338816 Oct 07 '16 at 14:01

3 Answers3

0

Could you try this;

In Data Project Explorer,

  • right clicked, properties
  • Driver properties
  • type your schema in Default schema
  • disconnect and reconnect database;

and try without SCHEMANAME.

Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24
0

Schema name defaults to your authorisation ID (user name in most cases). To use a different name to qualify unqualified object names, set the special register CURRENT_SCHEMA appropriately:

SET SCHEMA whatever
mustaccio
  • 18,234
  • 16
  • 48
  • 57
0

Best way in my eyes for Data Stuio is setting the special register "Current schema" on the Special Registers tab of the SQL Editor. Here is a screenshot enter image description here

MichaelTiefenbacher
  • 3,805
  • 2
  • 11
  • 17