8 use SQL::Translator::Schema::Constants;
9 use SQL::Translator::Schema::Table;
10 use SQL::Translator::Schema::View;
11 use SQL::Translator::Schema::Field;
12 use SQL::Translator::Schema::Constraint;
13 use SQL::Translator::Producer::Oracle;
16 my $table1 = SQL::Translator::Schema::Table->new( name => 'table1' );
18 my $table1_field1 = $table1->add_field(
20 data_type => 'NUMBER',
22 default_value => undef,
23 is_auto_increment => 0,
29 my $table1_field2 = $table1->add_field(
31 data_type => 'VARCHAR',
33 default_value => undef,
34 is_auto_increment => 0,
40 my $table2 = SQL::Translator::Schema::Table->new( name => 'table2' );
42 my $table2_field1 = $table2->add_field(
44 data_type => 'NUMBER',
46 default_value => undef,
47 is_auto_increment => 0,
53 my $table2_field2 = $table2->add_field(
55 data_type => 'VARCHAR',
57 default_value => undef,
58 is_auto_increment => 0,
64 my $constraint1 = $table1->add_constraint(
66 fields => [qw/ fk_col1 fk_col2 /],
67 reference_fields => [qw/ fk_col1 fk_col2 /],
68 reference_table => 'table2',
72 my ($table1_def, $fk1_def, $trigger1_def,
73 $index1_def, $constraint1_def
74 ) = SQL::Translator::Producer::Oracle::create_table($table1);
78 [ 'ALTER TABLE table1 ADD CONSTRAINT table1_fk_col1_fk_col2_fk FOREIGN KEY (fk_col1, fk_col2) REFERENCES table2 (fk_col1, fk_col2)'
80 'correct "CREATE CONSTRAINT" SQL'
83 my $materialized_view = SQL::Translator::Schema::View->new(
85 sql => 'SELECT id, name FROM table3',
89 'REFRESH START WITH SYSDATE NEXT SYSDATE + 5/1440 FORCE WITH ROWID'
93 my ($materialized_view_def) = SQL::Translator::Producer::Oracle::create_view($materialized_view);
95 $materialized_view_def,
96 [ "CREATE MATERIALIZED VIEW matview REFRESH START WITH SYSDATE NEXT SYSDATE + 5/1440 FORCE WITH ROWID AS\nSELECT id, name FROM table3"
98 'correct "CREATE MATERIALZED VIEW" SQL'