bulk inserts
am 27.11.2003 23:07:34 von Mayuran
Starting from MySQL 4, you can do bulk inserts like:
INSERT INTO table VALUES (a), (b), (c);
Is there anything in DBD::mysql to take advantage of this ?
Thanks
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: bulk inserts
am 28.11.2003 07:18:32 von Jochen Wiedmann
Mayuran wrote:
> Starting from MySQL 4, you can do bulk inserts like:
> INSERT INTO table VALUES (a), (b), (c);
>
> Is there anything in DBD::mysql to take advantage of this ?
As far as I can see there is no need for special support. It is
simply an SQL string, possibly with parameters.
Jochen
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: bulk inserts
am 28.11.2003 07:18:32 von Jochen Wiedmann
Mayuran wrote:
> Starting from MySQL 4, you can do bulk inserts like:
> INSERT INTO table VALUES (a), (b), (c);
>
> Is there anything in DBD::mysql to take advantage of this ?
As far as I can see there is no need for special support. It is
simply an SQL string, possibly with parameters.
Jochen
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: bulk inserts
am 03.12.2003 10:53:29 von Giuseppe Maxia
> Starting from MySQL 4, you can do bulk inserts like:
Actually, they have available for long, long time. I remember using them
with MySQL 3.23.30
> INSERT INTO table VALUES (a), (b), (c);
>
>Is there anything in DBD::mysql to take advantage of this ?
Not explicitly. But you can use a Perl idiom to create multi-values
INSERT statements:
my @values = (
["A", "B", "D", "0"], ["E", "F", "G", "1"],
["H", "I", "J", "2"], ["K", "L", "M", "3"],
["N", "O", "P", "4"], ["Q", "R", "S", "5"],
["T", "U", "V", "6"], ["W", "X", "Y", "7"],
);
my $query = "INSERT INTO mytable VALUES \n"
. join(",\n", ( map { "(". join ( ", ",
map {$dbh->quote($_)} @$_). ")"
}
@values));
print "$query;\n";
__END__
it will print
INSERT INTO mytable VALUES
('A', 'B', 'D', '0'),
('E', 'F', 'G', '1'),
('H', 'I', 'J', '2'),
('K', 'L', 'M', '3'),
('N', 'O', 'P', '4'),
('Q', 'R', 'S', '5'),
('T', 'U', 'V', '6'),
('W', 'X', 'Y', '7')
See http://gmax.oltrelinux.com/dbirecipes.html for more DBI idioms
--
____ ____ _____ _ _
/ _ | \(____ ( \ / )
( (_| | | | / ___ |) X (
\___ |_|_|_\_____(_/ \_)
(_____|
Sapere, saper fare, fare, far sapere
http://gmax.oltrelinux.com
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: bulk inserts
am 03.12.2003 10:53:29 von Giuseppe Maxia
> Starting from MySQL 4, you can do bulk inserts like:
Actually, they have available for long, long time. I remember using them
with MySQL 3.23.30
> INSERT INTO table VALUES (a), (b), (c);
>
>Is there anything in DBD::mysql to take advantage of this ?
Not explicitly. But you can use a Perl idiom to create multi-values
INSERT statements:
my @values = (
["A", "B", "D", "0"], ["E", "F", "G", "1"],
["H", "I", "J", "2"], ["K", "L", "M", "3"],
["N", "O", "P", "4"], ["Q", "R", "S", "5"],
["T", "U", "V", "6"], ["W", "X", "Y", "7"],
);
my $query = "INSERT INTO mytable VALUES \n"
. join(",\n", ( map { "(". join ( ", ",
map {$dbh->quote($_)} @$_). ")"
}
@values));
print "$query;\n";
__END__
it will print
INSERT INTO mytable VALUES
('A', 'B', 'D', '0'),
('E', 'F', 'G', '1'),
('H', 'I', 'J', '2'),
('K', 'L', 'M', '3'),
('N', 'O', 'P', '4'),
('Q', 'R', 'S', '5'),
('T', 'U', 'V', '6'),
('W', 'X', 'Y', '7')
See http://gmax.oltrelinux.com/dbirecipes.html for more DBI idioms
--
____ ____ _____ _ _
/ _ | \(____ ( \ / )
( (_| | | | / ___ |) X (
\___ |_|_|_\_____(_/ \_)
(_____|
Sapere, saper fare, fare, far sapere
http://gmax.oltrelinux.com
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org