GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SQL::Translator::Schema(3) User Contributed Perl Documentation SQL::Translator::Schema(3)

SQL::Translator::Schema - SQL::Translator schema object

  use SQL::Translator::Schema;
  my $schema   =  SQL::Translator::Schema->new(
      name     => 'Foo',
      database => 'MySQL',
  );
  my $table    = $schema->add_table( name => 'foo' );
  my $view     = $schema->add_view( name => 'bar', sql => '...' );

"SQL::Translator::Schema" is the object that accepts, validates, and returns the database structure.

Returns a Graph::Directed object with the table names for nodes.

Add a table object. Returns the new SQL::Translator::Schema::Table object. The "name" parameter is required. If you try to create a table with the same name as an existing table, you will get an error and the table will not be created.

  my $t1 = $schema->add_table( name => 'foo' ) or die $schema->error;
  my $t2 = SQL::Translator::Schema::Table->new( name => 'bar' );
  $t2    = $schema->add_table( $table_bar ) or die $schema->error;

Remove a table from the schema. Returns the table object if the table was found and removed, an error otherwise. The single parameter can be either a table name or an SQL::Translator::Schema::Table object. The "cascade" parameter can be set to 1 to also drop all triggers on the table, default is 0.

  $schema->drop_table('mytable');
  $schema->drop_table('mytable', cascade => 1);

Add a procedure object. Returns the new SQL::Translator::Schema::Procedure object. The "name" parameter is required. If you try to create a procedure with the same name as an existing procedure, you will get an error and the procedure will not be created.

  my $p1 = $schema->add_procedure( name => 'foo' );
  my $p2 = SQL::Translator::Schema::Procedure->new( name => 'bar' );
  $p2    = $schema->add_procedure( $procedure_bar ) or die $schema->error;

Remove a procedure from the schema. Returns the procedure object if the procedure was found and removed, an error otherwise. The single parameter can be either a procedure name or an SQL::Translator::Schema::Procedure object.

  $schema->drop_procedure('myprocedure');

Add a trigger object. Returns the new SQL::Translator::Schema::Trigger object. The "name" parameter is required. If you try to create a trigger with the same name as an existing trigger, you will get an error and the trigger will not be created.

  my $t1 = $schema->add_trigger( name => 'foo' );
  my $t2 = SQL::Translator::Schema::Trigger->new( name => 'bar' );
  $t2    = $schema->add_trigger( $trigger_bar ) or die $schema->error;

Remove a trigger from the schema. Returns the trigger object if the trigger was found and removed, an error otherwise. The single parameter can be either a trigger name or an SQL::Translator::Schema::Trigger object.

  $schema->drop_trigger('mytrigger');

Add a view object. Returns the new SQL::Translator::Schema::View object. The "name" parameter is required. If you try to create a view with the same name as an existing view, you will get an error and the view will not be created.

  my $v1 = $schema->add_view( name => 'foo' );
  my $v2 = SQL::Translator::Schema::View->new( name => 'bar' );
  $v2    = $schema->add_view( $view_bar ) or die $schema->error;

Remove a view from the schema. Returns the view object if the view was found and removed, an error otherwise. The single parameter can be either a view name or an SQL::Translator::Schema::View object.

  $schema->drop_view('myview');

Get or set the schema's database. (optional)

  my $database = $schema->database('PostgreSQL');

Returns true if all the tables and views are valid.

  my $ok = $schema->is_valid or die $schema->error;

Returns a procedure by the name provided.

  my $procedure = $schema->get_procedure('foo');

Returns all the procedures as an array or array reference.

  my @procedures = $schema->get_procedures;

Returns a table by the name provided.

  my $table = $schema->get_table('foo');

Returns all the tables as an array or array reference.

  my @tables = $schema->get_tables;

Returns a trigger by the name provided.

  my $trigger = $schema->get_trigger('foo');

Returns all the triggers as an array or array reference.

  my @triggers = $schema->get_triggers;

Returns a view by the name provided.

  my $view = $schema->get_view('foo');

Returns all the views as an array or array reference.

  my @views = $schema->get_views;

Creates foreign key relationships among like-named fields in different tables. Accepts the following arguments:
  • join_pk_only

    A True or False argument which determines whether or not to perform the joins from primary keys to fields of the same name in other tables

  • skip_fields

    A list of fields to skip in the joins

  $schema->make_natural_joins(
      join_pk_only => 1,
      skip_fields  => 'name,department_id',
  );

Get or set the schema's name. (optional)

  my $schema_name = $schema->name('Foo Database');

Get the SQL::Translator instance that instantiated the parser.

Ken Youens-Clark <kclark@cpan.org>.
2020-09-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.