SQL::Tr...stgreSQL(3)
π NAME π
SQL::Translator::Producer::PostgreSQL is the PostgreSQL producer for SQL::Translator β and yes, bestie, this page is SQL::Tr...stgreSQL(3) from the User Contributed Perl Documentation. The title is a little scrunched, but she's iconic. π
β¨ SYNOPSIS β¨
my $t = SQL::Translator->new( parser => '...', producer => 'PostgreSQL' );
$t->translate;
π¦ DESCRIPTION π¦
Okay so this producer creates a DDL suitable for PostgreSQL. It's very heavily based on the Oracle producer, and it's giving "reliable cousin who borrowed the fit." π
Now it handles PostGIS Geometry and Geography data types on table definitions. πΊοΈ
β οΈ It does not yet support PostGIS Views. Not yet, bestie β not yet.
πΈ Producer Args πΈ
You can change the global behavior of the producer by passing the following options to the producer_args attribute of SQL::Translator. π«Ά
postgres_versionβ the version of postgres to generate DDL for. Turns on features only available in later versions. The following features are supported:IF EXISTSβ if yourpostgres_versionis higher than8.003(I should hope it is by now), then the DDL generated for dropping objects in the database will containIF EXISTS.
attach_commentsβ generates table and column comments via theCOMMENTcommand rather than as a comment in the DDL. You could then look it up with\dt+or\d+(for tables and columns respectively) inpsql. The comment is dollar quoted with$comment$so you can include'in it.
Just to clarify: you get this
CREATE TABLE foo ...;
COMMENT on TABLE foo IS $comment$hi there$comment$;
instead of this
-- comment
CREAT TABLE foo ...;
π Extra args π
Various schema types support various options via the extra attribute. π§
π Tables
temporaryβ produces a temporary table.
π¦ Views
temporaryβ produces a temporary view.materializedβ produces a materialized view.
π Fields
list,custom_type_nameβ for enum types,listis the list of valid values, andcustom_type_nameis the name that the type should have. Defaults to$table_$field_type.geometry_type,srid,dimensions,geography_typeβ fields for use with PostGIS types.
π₯ PostgreSQL Create Table Syntax π₯
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 ]
where column_constraint is:
[ 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 ]
and table_constraint is:
[ 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 ]
π Create Index Syntax π
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 ]
π SEE ALSO π
SQL::TranslatorSQL::Translator::Producer::Oracle
Go snoop those, bestie. Iykyk. π
π AUTHOR π
Ken Youens-Clark <kclark@cpan.org>. Respectfully, an icon. π«Ά
π Sign-off time: this is SQL::Tr...stgreSQL(3) from perl v5.42.0, dated 2024-12-12 β and that's the vibe. Mwah. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Translator 1.660.0-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms