Name
Msql::listindex
Synopsis
@index_handles = $db->listindex($table,$index);
Msql::listindex
accepts the names of a table and
the name of an index as its arguments and returns an array of
statement handles containing information about each of the indices.
Although this function is documented as returning an array of
statement handles, we can find no case where more than one statement
handle would be returned. Therefore it is probably safe to treat this
function as returning a scalar statement handle. The statement handle
is of the same style as a statement handle returned by
Msql::query
and can be accessed by the same
functions. If the index does not exist, an undefined value
undef
is returned. The table of data returned
about the index has one column, which has the title
“Index”. The first row is the type of index, which in
mSQL 2.0 is always “avl”. The other rows are the names of
the fields that comprise the index. This function is valid only with
mSQL 2.0 or greater database servers.
Example
use Msql; my $db = Msql->connect; $db->selectdb('mydata'); my $mytable_fields = $db->listfields('mytable'); my @indices = $mytable_fields->listindices; # I now know the names of all of the indices. foreach (@indices) { my $index_info_handle = $db->listindex('mytable',$_); my (@index_info) = $index_info_handle->fetchcol(0); my $type_of_index = shift(@index_info); # $type_of_index now contains the type of the index (probably 'avl') # and @index_info now contains a list of the fields in the index. ...
Get MySQL and mSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.