Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jATze-0005Ll-2e for pgsql-general@arkaria.postgresql.org; Sat, 07 Mar 2020 07:35:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jATzc-0002Rf-Qx for pgsql-general@arkaria.postgresql.org; Sat, 07 Mar 2020 07:35:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jATzc-0002RY-FI for pgsql-general@lists.postgresql.org; Sat, 07 Mar 2020 07:35:28 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jATza-0003ZC-Cl for pgsql-general@postgresql.org; Sat, 07 Mar 2020 07:35:28 +0000 Received: by mail-wm1-x341.google.com with SMTP id p9so4798091wmc.2 for ; Fri, 06 Mar 2020 23:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5/TNjSRRKZ1cpMrWHyBVVWIgFfssZvfPCMU8G9NCXiU=; b=oMG2bsaxes4bZR8BVtAA1vTT2yjsM+mA5XuUbK/Vy26RpgcXecFRs0xpyzlRPe43QA RrKQPufrkGERMtr0zu3ucOYeXVzK+Tjxdi7NLKY4Z6aedBpJF6/bd2FP9zwgvQp2+cdh DOiNiMd3SLZwGSUfaNffkPm2LG4f4Lwoj4M/oheR55HweCrzjsOw1Tl03RmzTBdDuVuL gH4Qt5iMj2L8p4k4+G94NK86NCl0KKOykfnQ9JEsLBsvcPuGQ4KKvHKCCKYptaZ5hqm1 YyGLiHrjWqTSXMGAWD5/5qmkhvSFcho796lwf4h/w/O94cPAen5F6Nvex6ZtqEQg5P8B v41g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5/TNjSRRKZ1cpMrWHyBVVWIgFfssZvfPCMU8G9NCXiU=; b=rLS5DTPecQqNbGnuM1MonQhZ79nqQ7A9Kj3J5V3JYmjb8XZGtko/5ZVKv3utTJ21C5 J/Vg2bGNgHkua86E66BZTpebxV0Lk/vCWDQjyykAba6DuKS0O+EujiQMJ+6f4kRZcixS oevBrR5C+FMO2qkOosdkq4tkPjT5Tayh6aPKbh2uU6zcU8j8I4Mc5b8BnUJKrWAnpwTe YQ8iX3tZyTq86MjJtWiSC83ghN2ZDmkFH0yghAaBIGh0QxJt+wL3jkU2E8inhjiNHSC2 /EdtTGEeOkSwvzbqjb/FK0pQkxPVqSxZZUt+ALgCe9A+Ap+DcVEhCxbrhbPQoOfBxqBv fFZg== X-Gm-Message-State: ANhLgQ2fNcF+Kray4RwKMrTF57kTqMnoysTyOg6CqNF+V/8LzFknbj5A Mo4mcC9BrWj4FMr0YGR1yO8= X-Google-Smtp-Source: ADFU+vujJ3KpBm0Lflkt5/iYlk0HJgW114GUx96dorn0bqmU8f+8Ue7P3T3QipCJV7udNrwLnob6jg== X-Received: by 2002:a05:600c:2283:: with SMTP id 3mr8439860wmf.100.1583566524334; Fri, 06 Mar 2020 23:35:24 -0800 (PST) Received: from [192.168.1.145] (241-57-239-77.dyn.cable.fcom.ch. [77.239.57.241]) by smtp.gmail.com with ESMTPSA id f16sm43048531wrx.25.2020.03.06.23.35.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2020 23:35:23 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: Restrict user to create only one db with a specific name From: =?utf-8?Q?Paul_F=C3=B6rster?= In-Reply-To: Date: Sat, 7 Mar 2020 08:35:22 +0100 Cc: Forums postgresql Content-Transfer-Encoding: quoted-printable Message-Id: <395AEEFA-8532-48E1-B1AA-8155DB162349@gmail.com> References: To: Tiffany Thang X-Mailer: Apple Mail (2.3608.60.0.2.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Tiff, from what you say, it sounds that each user should have his or her own = database. Considering the other answers here already pointing out the = difficulties, why don't you just create a database for each user with = the same name as the username and grant him or her access to it. So, basically like this: postgres=3D# create role "userA" login; CREATE ROLE postgres=3D# create database "userA" owner "userA"; CREATE DATABASE postgres=3D# create role "userB" login; CREATE ROLE postgres=3D# create database "userB" owner "userB"; CREATE DATABASE When, say, "userB" goes away, his or her data will go the way all things = do: drop database "userB"; drop role "userB"; Or did I misunderstand you? Cheers, Paul > On 07. Mar, 2020, at 00:28, Tiffany Thang = wrote: >=20 > Hi, > Is there a way in PostgreSQL 12 to restrict user to creating a = database with a specific database name? >=20 > For example, userA can only create a database with a name called mydb. = Any other names would generate an error.=20 >=20 > If that is not possible, will it be possible then to limit userA to = creating only one database? Granting the createdb privilege would allow = the user to create any number of databases which I want to avoid. >=20 > Thanks. >=20 > Tiff