Re: DDL from psql console? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: DDL from psql console?
Date
Msg-id 200504251558.j3PFwIc18393@candle.pha.pa.us
Whole thread Raw
In response to Re: DDL from psql console?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> John Browne <jkbrowne@gmail.com> writes:
> > I was curious if there was a way to get the DDL for a particular table
> > from the psql client console?
>
> No.  Try
>     pg_dump -s -t tablename dbname

Oh, from psql:  :-)  (We really should have an easier way of show all
information from psql)

    test=> CREATE TABLE test (x SERIAL);
    NOTICE:  CREATE TABLE will create implicit sequence "test_x_seq" for
    serial column "test.x"
    CREATE TABLE
    test=> \! pg_dump -s -t test test
    --
    -- PostgreSQL database dump
    --

    SET client_encoding = 'SQL_ASCII';
    SET check_function_bodies = false;
    SET client_min_messages = warning;

    SET search_path = public, pg_catalog;

    SET default_tablespace = '';

    SET default_with_oids = false;

    --
    -- Name: test; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
    --

    CREATE TABLE test (
        x serial NOT NULL
    );


    ALTER TABLE public.test OWNER TO postgres;

    --
    -- PostgreSQL database dump complete
    --

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From: "Ben Trewern"
Date:
Subject: Re: Delphi personal (was Playing with PostgreSQL and Access VBA)
Next
From: John Browne
Date:
Subject: Re: DDL from psql console?