logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SQL::Translator::Producer::PostgreSQL - PostgreSQL producer for SQL::Translator

Author

       Ken Youens-Clark <kclark@cpan.org>.

perl v5.40.0                                       2024-11-23              SQL::Translato...cer::PostgreSQL(3pm)

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 ]

Description

       Creates a DDL suitable for PostgreSQL.  Very heavily based on the Oracle producer.

       Now handles PostGIS Geometry and Geography data types on table definitions.  Does not yet support PostGIS
       Views.

   ProducerArgs
       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 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.

       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 \dt+ or \d+ (for tables and columns respectively) in psql. 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 ...;

   Extraargs
       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,  list  is  the list of valid values, and custom_type_name is the name that the type
           should have. Defaults to $table_$field_type.

         geometry_type, srid, dimensions, geography_type
           Fields for use with PostGIS types.

Name

       SQL::Translator::Producer::PostgreSQL - PostgreSQL producer for SQL::Translator

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 ]

See Also

       SQL::Translator, SQL::Translator::Producer::Oracle.

Synopsis

         my $t = SQL::Translator->new( parser => '...', producer => 'PostgreSQL' );
         $t->translate;

See Also