8 use SQL::Translator::Schema::Constants;
9 use SQL::Translator::Schema::Table;
10 use SQL::Translator::Schema::Field;
11 use SQL::Translator::Schema::Constraint;
12 use SQL::Translator::Producer::Oracle;
15 my $table1 = SQL::Translator::Schema::Table->new( name => 'table1' );
17 my $table1_field1 = $table1->add_field(
19 data_type => 'NUMBER',
21 default_value => undef,
22 is_auto_increment => 0,
28 my $table1_field2 = $table1->add_field(
30 data_type => 'VARCHAR',
32 default_value => undef,
33 is_auto_increment => 0,
39 my $table2 = SQL::Translator::Schema::Table->new( name => 'table2' );
41 my $table2_field1 = $table2->add_field(
43 data_type => 'NUMBER',
45 default_value => undef,
46 is_auto_increment => 0,
52 my $table2_field2 = $table2->add_field(
54 data_type => 'VARCHAR',
56 default_value => undef,
57 is_auto_increment => 0,
63 my $constraint1 = $table1->add_constraint(
65 fields => [qw/ fk_col1 fk_col2 /],
66 reference_fields => [qw/ fk_col1 fk_col2 /],
67 reference_table => 'table2',
71 my ($table1_def, $fk1_def, $trigger1_def,
72 $index1_def, $constraint1_def
73 ) = SQL::Translator::Producer::Oracle::create_table($table1);
77 [ 'ALTER TABLE table1 ADD CONSTRAINT table1_fk_col1_fk_col2_fk FOREIGN KEY (fk_col1, fk_col2) REFERENCES table2 (fk_col1, fk_col2)'
79 'correct "CREATE CONSTRAINT" SQL'