1

When connecting to an h2 database, the default search path is set to public. You can alter it with the SET SCHEMA_SEARCH_PATH.

But if you alter it multiple times, at some point how can you view its current content?

I wasn't able to find some kind of commands like this VIEW SCHEMA_SEARCH_PATH or SHOW SCHEMA_SEARCH_PATH.

Typing them give me error messages.

Stephan
  • 41,764
  • 65
  • 238
  • 329

2 Answers2

2

It's a bit a hack, but you could use:

SELECT * FROM INFORMATION_SCHEMA.SESSION_STATE 
WHERE KEY='SCHEMA_SEARCH_PATH'
Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
0

Non-hack solution: SELECT SCHEMA()

Serge
  • 9
  • 1
  • I tried connecting with this url: `jdbc:h2:mem:;INIT=create schema if not exists po;SCHEMA_SEARCH_PATH=PO,INFORMATION_SCHEMA,PUBLIC`. `SELECT SCHEMA()` returned only PUBLIC whereas Thomas' solution printed the expected schema search_path. **h2 1.4.193** – Stephan Mar 01 '17 at 15:25
  • Agreed, search path isn't the same as current schema and may include multiple schemas. Current schema is important when you execute some DDL, for SELECTs search_path is more relevant. – Serge Mar 01 '17 at 21:47