Postgresql: how to create table only if it does not already exist?

后端 未结 10 948
不思量自难忘°
不思量自难忘° 2021-01-31 08:04

In Postgresql, how can I do a condition to create a table only if it does not already exist?

Code example appreciated.

10条回答
  •  心在旅途
    2021-01-31 08:13

    The easiest answer is :

    catch{
    
    #create table here
    
    }
    

    This creates a table if not exists and produces an error if exists. And the error is caught.

提交回复
热议问题