Postgresql: Check if Schema Exists?

前端 未结 10 1562
星月不相逢
星月不相逢 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:39

    This can be one of the approaches. Drop the schema first and then create it.

    IF EXISTS:
    Do not throw an error if the schema does not exist. A notice is issued in this case.
    

    So,

    DROP SCHEMA IF EXISTS schema_Name
    Create SCHEMA schema_Name
    

提交回复
热议问题