| version 1.33, 2008/08/23 18:54:00 |
version 1.34, 2008/08/23 19:21:26 |
|
|
| #!/usr/bin/perl |
#!/usr/bin/perl |
| |
|
| # $Platon: scripts/perl/oracle/oracledump.pl,v 1.32 2008-08-23 18:45:25 nepto Exp $ |
# $Platon: scripts/perl/oracle/oracledump.pl,v 1.33 2008-08-23 18:54:00 nepto Exp $ |
| |
|
| use strict; |
use strict; |
| |
|
| Line 266 $dbh = DBI->connect("dbi:Oracle:$opt_dat |
|
| Line 266 $dbh = DBI->connect("dbi:Oracle:$opt_dat |
|
| $opt_password) |
$opt_password) |
| || die "Cannot connect to database: $DBI::errstr"; |
|| die "Cannot connect to database: $DBI::errstr"; |
| |
|
| |
|
| #*********************************************************************** |
#*********************************************************************** |
| # Turn autocommit *off* and set transaction to *read only* |
# Turn autocommit *off* and set transaction to *read only* |
| #*********************************************************************** |
#*********************************************************************** |
|
|
| nullable |
nullable |
| FROM all_tab_columns |
FROM all_tab_columns |
| WHERE data_type != \'XMLTYPE\' |
WHERE data_type != \'XMLTYPE\' |
| |
AND data_type != \'AQ$_SUBSCRIBERS\' |
| AND UPPER(table_name) = \''.$table.'\' |
AND UPPER(table_name) = \''.$table.'\' |
| AND UPPER(owner) = \''.$opt_owner.'\''; |
AND UPPER(owner) = \''.$opt_owner.'\''; |
| } else { |
} else { |
|
|
| nullable |
nullable |
| FROM user_tab_columns |
FROM user_tab_columns |
| WHERE data_type != \'XMLTYPE\' |
WHERE data_type != \'XMLTYPE\' |
| |
AND data_type != \'AQ$_SUBSCRIBERS\' |
| AND UPPER(table_name) = \''.$table.'\''; |
AND UPPER(table_name) = \''.$table.'\''; |
| } |
} |
| |
|
|
|
| |
|
| if ( !defined $opt_no_create_info ) { |
if ( !defined $opt_no_create_info ) { |
| if ($opt_mysql_compliant_dump) { |
if ($opt_mysql_compliant_dump) { |
| if ($row[5] =~ /^to_date/i or $row[5] =~ /^USER/i or $row[5] =~ /\(\)/) { |
if ($row[5] =~ /^to_date/i or $row[5] =~ /^(USER|UID)/i or $row[5] =~ /\(\)/) { |
| undef $row[5]; |
undef $row[5]; |
| } elsif ($row[5] =~ /\((.*)\)/) { |
} elsif ($row[5] =~ /\((.*)\)/) { |
| $row[5] = $1; |
$row[5] = $1; |
|
|
| ? 'TEXT' : 'VARCHAR(' . $row[2] . ')' ) |
? 'TEXT' : 'VARCHAR(' . $row[2] . ')' ) |
| : ( $row[1] eq 'DATE' |
: ( $row[1] eq 'DATE' |
| ? 'DATETIME' |
? 'DATETIME' |
| : ( (($row[1] eq 'CLOB') or ($row[1] =~ /RAW/) or ($row[1] eq 'PRACFOND')) |
: ( (($row[1] eq 'CLOB') or ($row[1] eq 'NCLOB') or ($row[1] eq 'PRACFOND')) |
| ? 'BLOB' : $row[1] ) ) ) ), |
? 'BLOB' |
| |
: ($row[1] =~ /RAW/i |
| |
? 'BLOB' # some MySQL's RAW equivalent should be here |
| |
: $row[1]) ) ) ) ), |
| ( defined $row[5] |
( defined $row[5] |
| ? ((($row[5] =~ /^SYSDATE/i) or ($row[1] eq 'BLOB')) ? '' : 'DEFAULT ' . $row[5]) |
? ((($row[5] =~ /^SYSDATE/i) or ($row[1] =~ /RAW/i)) ? '' : 'DEFAULT ' . $row[5]) |
| : '' ), |
: '' ), |
| ( $row[6] eq 'Y' |
( $row[6] eq 'Y' |
| ? '' |
? '' |
| Line 634 sub escape_data($$) |
|
| Line 638 sub escape_data($$) |
|
| $value =~ s/'/\\'/gm; |
$value =~ s/'/\\'/gm; |
| $value =~ s/"/\\"/gm; |
$value =~ s/"/\\"/gm; |
| $value =~ s/\x00/<--N--U--L-->/gm; |
$value =~ s/\x00/<--N--U--L-->/gm; |
| return "'$value'"; |
return "'$value'"; |
| } |
} |
| } elsif ($type eq 'DATE' or $type eq 'TIMESTAMP' or $type eq 'TIMESTAMP(6)') { |
} elsif ($type eq 'DATE' or $type eq 'TIMESTAMP' or $type eq 'TIMESTAMP(6)') { |
| if ( !defined $value ) { |
if ( !defined $value ) { |