.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SQL::Translator::Producer::PostgreSQL 3pm" .TH SQL::Translator::Producer::PostgreSQL 3pm 2024-01-20 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SQL::Translator::Producer::PostgreSQL \- PostgreSQL producer for SQL::Translator .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& my $t = SQL::Translator\->new( parser => \*(Aq...\*(Aq, producer => \*(AqPostgreSQL\*(Aq ); \& $t\->translate; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Creates a DDL suitable for PostgreSQL. Very heavily based on the Oracle producer. .PP Now handles PostGIS Geometry and Geography data types on table definitions. Does not yet support PostGIS Views. .SS "Producer Args" .IX Subsection "Producer Args" You can change the global behavior of the producer by passing the following options to the \&\f(CW\*(C`producer_args\*(C'\fR attribute of \f(CW\*(C`SQL::Translator\*(C'\fR. .IP postgres_version 4 .IX Item "postgres_version" The version of postgres to generate DDL for. Turns on features only available in later versions. The following features are supported .RS 4 .IP "IF EXISTS" 4 .IX Item "IF EXISTS" If your postgres_version is higher than 8.003 (I should hope it is by now), then the DDL generated for dropping objects in the database will contain IF EXISTS. .RE .RS 4 .RE .IP attach_comments 4 .IX Item "attach_comments" Generates table and column comments via the COMMENT command rather than as a comment in the DDL. You could then look it up with \edt+ or \ed+ (for tables and columns respectively) in psql. The comment is dollar quoted with \f(CW$comment\fR$ so you can include ' in it. Just to clarify: you get this .Sp .Vb 2 \& CREATE TABLE foo ...; \& COMMENT on TABLE foo IS $comment$hi there$comment$; .Ve .Sp instead of this .Sp .Vb 2 \& \-\- comment \& CREAT TABLE foo ...; .Ve .SS "Extra args" .IX Subsection "Extra args" Various schema types support various options via the \f(CW\*(C`extra\*(C'\fR attribute. .IP Tables 2 .IX Item "Tables" .RS 2 .PD 0 .IP temporary 2 .IX Item "temporary" .PD Produces a temporary table. .RE .RS 2 .RE .IP Views 2 .IX Item "Views" .RS 2 .PD 0 .IP temporary 2 .IX Item "temporary" .PD Produces a temporary view. .IP materialized 2 .IX Item "materialized" Produces a materialized view. .RE .RS 2 .RE .IP Fields 2 .IX Item "Fields" .RS 2 .PD 0 .IP "list, custom_type_name" 2 .IX Item "list, custom_type_name" .PD For enum types, list is the list of valid values, and custom_type_name is the name that the type should have. Defaults to \f(CW$table_\fR$field_type. .IP "geometry_type, srid, dimensions, geography_type" 2 .IX Item "geometry_type, srid, dimensions, geography_type" Fields for use with PostGIS types. .RE .RS 2 .RE .SH "PostgreSQL Create Table Syntax" .IX Header "PostgreSQL Create Table Syntax" .Vb 6 \& CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name ( \& { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ] \& | table_constraint } [, ... ] \& ) \& [ INHERITS ( parent_table [, ... ] ) ] \& [ WITH OIDS | WITHOUT OIDS ] .Ve .PP where column_constraint is: .PP .Vb 6 \& [ CONSTRAINT constraint_name ] \& { NOT NULL | NULL | UNIQUE | PRIMARY KEY | \& CHECK (expression) | \& REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ] \& [ ON DELETE action ] [ ON UPDATE action ] } \& [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] .Ve .PP and table_constraint is: .PP .Vb 8 \& [ CONSTRAINT constraint_name ] \& { UNIQUE ( column_name [, ... ] ) | \& PRIMARY KEY ( column_name [, ... ] ) | \& CHECK ( expression ) | \& EXCLUDE [USING acc_method] (expression) [INCLUDE (column [, ...])] [WHERE (predicate)] \& FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] \& [ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] } \& [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] .Ve .SH "Create Index Syntax" .IX Header "Create Index Syntax" .Vb 7 \& CREATE [ UNIQUE ] INDEX index_name ON table \& [ USING acc_method ] ( column [ ops_name ] [, ...] ) \& [ INCLUDE ( column [, ...] ) ] \& [ WHERE predicate ] \& CREATE [ UNIQUE ] INDEX index_name ON table \& [ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] ) \& [ WHERE predicate ] .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" SQL::Translator, SQL::Translator::Producer::Oracle. .SH AUTHOR .IX Header "AUTHOR" Ken Youens-Clark .