Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDII4-0005Bq-2s for pgsql-general@arkaria.postgresql.org; Tue, 10 Aug 2021 03:18:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mDII3-0001ly-21 for pgsql-general@arkaria.postgresql.org; Tue, 10 Aug 2021 03:18:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDII2-0001jY-No for pgsql-general@lists.postgresql.org; Tue, 10 Aug 2021 03:18:54 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mDIHy-0006gt-4V for pgsql-general@lists.postgresql.org; Tue, 10 Aug 2021 03:18:54 +0000 Received: by mail-qt1-x835.google.com with SMTP id h10so4661095qtj.11 for ; Mon, 09 Aug 2021 20:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=PiORtG6XeSjnB1Kxx3G3i12OaeZ5kXb/VC2CR1qOuO8=; b=W6uhftqlMziGfzaqtDZQ/F25tZ3xMIvdvlvCmshe+KnNlkPIdq9wQ5i1R6jkW+BX/T eEi3LaHQlZTqw9Z+syDouWCypBf7sRJVt+Mz95MhGHaEPawQhg8S2MlK2XbQuE3Cbe3A cUUha7kUVcE6VLkFi1nxUuvJLgjGIw9C13lu0JQeNY1D66TQEutRrhlAf0/uDGBL8f84 WWocQPcz5/fW2LM4OylW1HYTpJbMb9FsoQUT8Mr8xZfY2T0aA+rT6YzrqbZisff/0kQR 4hEWe3cAx0LB8xf7lF/AZ+pZKInChJaFIBD1zEOE4HHeawjdxVoHbSv31W8gxGUPamDa s3LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=PiORtG6XeSjnB1Kxx3G3i12OaeZ5kXb/VC2CR1qOuO8=; b=OpGwF+l8Bml/KlNUltD8eXAViRavIzlreZDZPm7+gWYISEVmg+Ywd5jjs0czBTCckO qf3F4/5ytUzIcIqHeWlUb6rSAGBGtpSbYKshlN7qFXbfgS9oSAzavtgV2Qfn4Ds+Xw7G xs3R5hfanjjvLabvpxu6w733mV6xJamZrgHIx15v3BnL1Ek7r7V1yvRQzy7S3dMe/t+B 2Gj5+1COaiUxDP89U3jBl8XRXTxg9pkgG7pZ8y+WqNlERRyZgOKmlFc2ioo1cSy/Fn4+ 3nfmPCp55HQK91mkF8XOJbh57UVwfVwv7Go4JhT3qR9DAckJpZfumW4KZE6wEkbxbCPt ofIQ== X-Gm-Message-State: AOAM532ytWK/XDQYSW9ZODA85qAlIBsH43/bI3ws3iUZoOtL8XPvyS1r 8DYzOTJlTYy4sBwO6P+UwSjeZxpVEpA/Kw== X-Google-Smtp-Source: ABdhPJyd5ySDaOw+oiLQ7A1XaHtuHp7pHCroAac01aN+68SRXjJ2QLxQJCTjqWTH5cCCIwMghXEWew== X-Received: by 2002:a05:622a:651:: with SMTP id a17mr6230901qtb.281.1628565527523; Mon, 09 Aug 2021 20:18:47 -0700 (PDT) Received: from [192.168.2.100] (pool-100-8-54-81.nwrknj.fios.verizon.net. [100.8.54.81]) by smtp.gmail.com with ESMTPSA id y199sm10545404qkb.36.2021.08.09.20.18.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Aug 2021 20:18:46 -0700 (PDT) Subject: Re: Serious List of PostgreSQL usage questions. To: pgsql-general@lists.postgresql.org References: From: Mladen Gogala Message-ID: <3a6a79fe-c60a-f264-f291-111eafce326e@gmail.com> Date: Mon, 9 Aug 2021 23:18:46 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------E80C1A0ADA497544247381DB" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------E80C1A0ADA497544247381DB Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Responses in-line: On 8/9/21 10:01 PM, A Z wrote: > 1) Are there free scripts for CREATE TYPE (native type), more > advanced, or sorts of types out there, online, free > for commercial use? With function support, too? Can someone reply with > a link or a suggestion? ORAFCE? That extension has Oracle date/time functions. > > 2) How may I get PostgreSQL to output the create table statement(s) > for one or more tables inside one database, without issuing > instructions via the command line, but only inside a database login, > as a query or pl/sql? Postgres doesn't store DDL into the catalog, DDL has to be created from the catalog data. I would advise pg_tables, pg_attribute and pg_indexes. That shouldn't be too hard of an exercise with PlPgSQL, If you want, you can play with the ddlx extension: https://pgxn.org/dist/ddlx/ > > 3) I know that I can use COPY to import or export one database table > between it and a *.csv file. Can I use it to do this with multiple > TABLES and *.csv files specified in one COPY COMMAND, or not? You can not. Copy does only one table at one time. Of course, you can use "screen" and do multiple tables from multiple windows or something similar. > > 4) In the absence of OS command line instructions, is there an > internal PostgreSQL way, via COPY or another function for example, to > backup an entire database, with all it's create table statements and > all insert statements, and any other associated object, in one hit? Or > is this ill-advised? Postgres pg_dump utility will do that. The results should be interesting for a muti-TB database. BTW, any backup utility, even the plain and simple pg_basebackup with --format=tar will be able to restore the database and recover the database. You can always reconstruct the DDL with pg_dump --schema-only. PgAdmin4 will also provide the DDL on request. > > 5) When setting up communication to remote databases on remote > machines, I need to use the OPTIONS() function. It seems to require as > its first function parameter, the schema of the table (the second > parameter) that it wants to access. Can I supply a null schema, and > still be able to reference the remote table, or must I also make use > of IMPORT FOREIGN SCHEMA? > > 6) I have found that the native trigonometry functions, namely the > radians versions, do produce error results around key trigonometry > input values. I have discovered that these errors persist, even if I > cast the input parameter away from DOUBLE PRECISION and into DECIMAL. > I would like to know if there are any freely available scripts out > there that include Arbitrary Precision mathematical functions support > that work on DECIMAL and not on DOUBLE PRECISION, that do not produce > any error values around key inputs? Could someone refer me to a > website that has a script that is such? PlPgPython can use numpy: https://numpy.org -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------E80C1A0ADA497544247381DB Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit

Responses in-line:


On 8/9/21 10:01 PM, A Z wrote:
1) Are there free scripts for CREATE TYPE (native type), more advanced, <date> or <datetime> sorts of types out there, online, free for commercial use? With function support, too? Can someone reply with a link or a suggestion?


ORAFCE? That extension has Oracle date/time functions.



2) How may I get PostgreSQL to output the create table statement(s) for one or more tables inside one database, without issuing instructions via the command line, but only inside a database login, as a query or pl/sql?

Postgres doesn't store DDL into the catalog, DDL has to be created from the catalog data. I would advise pg_tables, pg_attribute and pg_indexes. That shouldn't be too hard of an exercise with PlPgSQL, If you want, you can play with the ddlx extension: https://pgxn.org/dist/ddlx/



3) I know that I can use COPY to import or export one database table between it and a *.csv file. Can I use it to do this with multiple TABLES and *.csv files specified in one COPY COMMAND, or not?

You can not. Copy does only one table at one time. Of course, you can use "screen" and do multiple tables from multiple windows or something similar.



4) In the absence of OS command line instructions, is there an internal PostgreSQL way, via COPY or another function for example, to backup an entire database, with all it's create table statements and all insert statements, and any other associated object, in one hit? Or is this ill-advised?
Postgres pg_dump utility will do that. The results should be interesting for a muti-TB database. BTW, any backup utility, even the plain and simple pg_basebackup with --format=tar will be able to restore the database and recover the database. You can always reconstruct the DDL with pg_dump --schema-only. PgAdmin4 will also provide the DDL on request.

5) When setting up communication to remote databases on remote machines, I need to use the OPTIONS() function. It seems to require as its first function parameter, the schema of the table (the second parameter) that it wants to access. Can I supply a null schema, and still be able to reference the remote table, or must I also make use of IMPORT FOREIGN SCHEMA?

6) I have found that the native trigonometry functions, namely the radians versions, do produce error results around key trigonometry input values. I have discovered that these errors persist, even if I cast the input parameter away from DOUBLE PRECISION and into DECIMAL. I would like to know if there are any freely available scripts out there that include Arbitrary Precision mathematical functions support that work on DECIMAL and not on DOUBLE PRECISION, that do not produce any error values around key inputs? Could someone refer me to a website that has a script that is such?

PlPgPython can use numpy: https://numpy.org


-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------E80C1A0ADA497544247381DB--