Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s2VDB-003XxI-2U for pgsql-general@arkaria.postgresql.org; Thu, 02 May 2024 12:06:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s2VD8-0005re-Hz for pgsql-general@arkaria.postgresql.org; Thu, 02 May 2024 12:06:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s2VD8-0005rW-7E for pgsql-general@lists.postgresql.org; Thu, 02 May 2024 12:06:51 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s2VD6-0014tI-JP for pgsql-general@postgresql.org; Thu, 02 May 2024 12:06:49 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-61b92a83216so88935857b3.2 for ; Thu, 02 May 2024 05:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714651607; x=1715256407; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7kwW+hB9sG+rBXIt42My9dajKYUtNPHTwCzhmnF78YU=; b=EREllt479Nf2VD36KOr17l4w6bk20tYIuWPKvN0KntiBOZvxuEe5KG13Gp9084DcnQ yqBg+tl5UQ1Lgk4uK4M4DS1+1+RAeU6GYEt6bCjl8MFdSk7cBV48EtlYR2mTWe53XDYl Z/HEm26LjZe7f0l9sBVgf3eVYE7a6+r74tumrd5S90FLPRI7CmeWxE/uP/zaBc955nwN KS0mBfP1HiawigXctREQnIAaCJob5PfFN2hSYU6ygRrNogSy3Eahw3P1geZpxVcRJykQ FEntOO9auwy0lEgaQtHBGG3agYFZzcv0JQai3zK+llxvRzByGCHlqw+S6QQtr0sZGeOx 3nvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714651607; x=1715256407; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7kwW+hB9sG+rBXIt42My9dajKYUtNPHTwCzhmnF78YU=; b=Bmd+VJEWzIWus7b0xir8kiJFLBH+BzkwGhW1DW3aArT1oerSZnfDXSxnF+bQaq45dv lGyVKqIZDuYhvwi/rNj8WIzD+ldHPUoMWN9g5tqK7DKfW8imowq8NMbjFWOEp3bnUq4/ Tloe8QoMuD7bqSxXBNBw/CGCjXre5MUEc43OV9dObDmyXwMRv2/5xktjQ9VSEE4aenSF WBI7FQO1qoyN2KU6DSkoL0Juc8pIBmUhcOl+cIFx3kaW6GjxY2/4SuXg81u8WNzXeqLF QTbgmzuciL8zoyV1W8XzFT95Wx/IlrJIPj2+gJ/HY68i20V420E7qbbjSisfSLP+/8ig DRRA== X-Gm-Message-State: AOJu0Yy5LnM9ET4mUoP4DhU4+5scpah+ge+lplRTRK+npn412wrTRFEP 7EWo+UfMc1Cf+VbA6P9IVS9JfmGwQkvdeljaNGchpV+zXeryE1FjJQktKJGonK+JAC/9lpqjA3v sE6NphpIawQFP5H0ICN3qcmIUmnc= X-Google-Smtp-Source: AGHT+IE+EzYmXRwMaoFT1srvxJhXqijDeDyXwAmTAUZR+4kAJvgDlNAvVZyyeotF3Hw4z3agzksHu3qANkqLObxUr5M= X-Received: by 2002:a05:690c:6401:b0:618:e5c:f7a with SMTP id hr1-20020a05690c640100b006180e5c0f7amr6114636ywb.33.1714651607417; Thu, 02 May 2024 05:06:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kashif Zeeshan Date: Thu, 2 May 2024 17:06:35 +0500 Message-ID: Subject: Re: Listing only the user defined types (with owners) To: Durumdara Cc: Postgres General Content-Type: multipart/alternative; boundary="000000000000f97c900617776fa8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f97c900617776fa8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi You can find all user defined types with the following query. CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed'); SELECT typname FROM pg_catalog.pg_type JOIN pg_catalog.pg_namespace ON pg_namespace.oid =3D pg_type.typnamespace WHERE typtype =3D 'e' and nspname NOT IN ('pg_catalog', 'information_schema'); typname ----------------------- bug_status The values for typtype are as follows typtype is b for a base type, c for a composite type (e.g., a table's row type), d for a domain, e for an enum type, p for a pseudo-type, or r for a range type. See also typrelid and typbasetype. Regards Kashif Zeeshan Bitnine Global On Thu, May 2, 2024 at 4:40=E2=80=AFPM Durumdara wrot= e: > Hello! > > I have a script which can change the table owners to the database owner. > > I select the tables like this: > > FOR r IN SELECT tablename FROM pg_tables WHERE (schemaname =3D 'publi= c') > and (tableowner <> act_dbowner) > LOOP > ... > > For types I found pg_type, but this contains all types. > > For example I have only one user defined type, like "T_TEST", but this > pg_type relation contains the basic data types, other data types, from a= ny > schema. > > Do you have a working Query which lists the user defined types with the > owners? > > Thank you for your help! > > Best regards > dd > > > --000000000000f97c900617776fa8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

You can find all user defined types = with the following query.

CREATE TYPE bug_status A= S ENUM ('new', 'open', 'closed');
SELECT typname
FROM pg_catalog.pg_type
=C2=A0 JOIN pg_cat= alog.pg_namespace
=C2=A0 ON pg_namespace.oid =3D pg_type.typnamespaceWHERE
typtype =3D 'e' and nspname NOT IN ('pg_catalog',= 'information_schema');
=C2=A0 =C2=A0 =C2=A0 =C2=A0 typname
-= ----------------------
=C2=A0bug_status

The= values for=C2=A0typtype=C2=A0are as follows
typtype is b for a b= ase type, c for a composite type (e.g., a table's row type), d for a do= main, e for an enum type, p for a pseudo-type, or r for a range type. See a= lso typrelid and typbasetype.


R= egards
Kashif Zeeshan
Bitnine Global

On Thu, May 2= , 2024 at 4:40=E2=80=AFPM Durumdara <durumdara@gmail.com> wrote:
Hello!

I have a = script which can change the table owners to the database owner.
<= br>
I select the tables like this:

=C2=A0 =C2=A0 FOR r IN SELECT tablename FROM pg_tables = WHERE (schemaname =3D 'public') and (tableowner <> act_dbowne= r)
=C2=A0 =C2=A0 LOOP
...

= For types I found pg_type, but this contains all types.

For example I have only one user defined type, like "T_TEST"= ;, but this pg_type relation contains the basic data types,=C2=A0 other dat= a types, from any schema.

Do you have a working Qu= ery which lists the user defined types with the owners?

Thank you for=C2=A0your help!

Best regards
dd


--000000000000f97c900617776fa8--