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