刘志伟 发表于 2023-9-14 12:22:29

PostgreSQL:是否存在检查模式?

我需要动态创建、管理和删除模式。如果我想创建一个现有的模式,我想删除它,并以指定的方式重新创建它。如何检查我的Postgres
上述模式是否存在于服务器上?
目前,我正在这样做:
select exists (select * from pg_catalog.pg_namespace where nspname = 'schemaname');但我认为可能还有另一种方法……这是查询Postgres是否存在特定模式的“正确”方法吗?
                                                               
    解决方案:                                                               
                                                                以下查询将告诉您模式是否存在。
SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'name
页: [1]
查看完整版本: PostgreSQL:是否存在检查模式?