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.89) (envelope-from ) id 1h5RUT-0005v8-Pe for pgsql-gui-dev@arkaria.postgresql.org; Sun, 17 Mar 2019 08:49:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5RUS-0004y0-3P for pgsql-gui-dev@arkaria.postgresql.org; Sun, 17 Mar 2019 08:49:56 +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 1h5RUR-0004uz-S4 for pgsql-gui-dev@lists.postgresql.org; Sun, 17 Mar 2019 08:49:55 +0000 Received: from mimolette.dalibo.net ([212.85.157.144] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5RUP-0005Na-7Q for pgsql-gui-dev@lists.postgresql.org; Sun, 17 Mar 2019 08:49:55 +0000 Received: from webmail2.dalibo.info (mimolette.dalibo.net [212.85.157.144]) by mail.dalibo.com (Postfix) with ESMTPSA id B26F62C04ED for ; Sun, 17 Mar 2019 09:49:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.info; s=a; t=1552812591; bh=j5DsZxW7cebjJ8Jcz3fLHurUTrfrQcipdokim+EujAI=; h=Date:From:To:Subject:From; b=m2YnppNyruZkabe4e4RrLpOXLoSYHffbsNDuO5XkpNeofq7AZtX+cRaePuIHLz/Rp RXNurj8lHdJaVCa878NhglFx15QSmUEUv0yzmmq4TbFP9I5sFfNEALX8dB/1+ScjuS KjjmLuFKK2hhD8/IK2K6CpxOpzeVEGdx/RNaAUMk= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sun, 17 Mar 2019 09:49:50 +0100 From: Damien Clochard To: pgsql-gui-dev@lists.postgresql.org Subject: Export the CREATE TABLE command in pure SQL Message-ID: <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> X-Sender: damien@dalibo.info User-Agent: Roundcube Webmail/1.3.8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk hey guys, The most effective and simplest way to export the creation command of a table is to use `pg_dump --schema-only` However for one my projects, I don't have access to pg_dump and I need to extract the data with a SQL or pl/pgsql function. I already wrote a naïve implementation that handles primary keys and temporary tables. But I realize it's probably incomplete and I will have to maintain it for every new PostgreSQL major version.... How do you guys deal with this ? It seems that a lot of GUI tools are able to "export the table structure".... Is there an extension somewhere to do that ? Is it possible to write i in pure SQL ? If yes, there anybody here interested in joining forces to build a shared export function ? Have nice day ! -- Damien Clochard