Postgresql: Check if Schema Exists?

前端 未结 10 1567
星月不相逢
星月不相逢 2021-02-01 12:24

I need to create, manage and drop schemas on the fly. If I go to create a schema that already exists, I want to (conditionally, via external means) drop and recreate it as speci

10条回答
  •  粉色の甜心
    2021-02-01 12:43

    From http://www.postgresql.org/docs/9.1/static/infoschema-schemata.html (emphasis my own):

    The view schemata contains all schemas in the current database that are owned by a currently enabled role.

    So your original solution/query is more reliable than Peter's, albeit non-standard.

提交回复
热议问题