Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><em>How can obtain only the tables (without doing a uniq)</em></p> </blockquote> <p>The <code>$dbh-&gt;tables</code> interface is too simple, I'd guess, to represent the complexity of SQL engines and the various drivers. As you noticed, you should use <code>table_info()</code> instead.</p> <p>In particular, see the <a href="http://search.cpan.org/~ishigaki/DBD-SQLite/lib/DBD/SQLite.pm#table_info" rel="nofollow">DBD::SQLite documentation for <code>table_info()</code></a> (v1.39 at the time of writing), as DBD docs can tell you what features are supported by the db and driver (e.g., SQLite has no catalogs). Something like this will give you what you want:</p> <pre><code>use feature qw(say); ... # Get info on every ('%') TABLE entity in the "main" schema. Catalog is blank # b/c DBD::SQLite and/or SQLite itself has no concept of catalogs. my $sth = $dbh-&gt;table_info('', 'main', '%', 'TABLE'); while (my $r = $sth-&gt;fetchrow_hashref) { # outputs: table_a say $r-&gt;{TABLE_NAME}; # table_b } </code></pre> <blockquote> <p><em>and why there is one row for each index?</em></p> </blockquote> <p>Unsure, but probably an accident of <code>tables()</code> simple interface. Again, use <code>table_info()</code> to enumerate tables and table-like objects.</p> <blockquote> <p><em>How can I obtain the indexes info?</em></p> </blockquote> <p>The experimental <code>statistics_info()</code> method <em>might</em> be supported.</p> <blockquote> <p><em>and all together, how to obtain the equivalent info of .schema?</em></p> </blockquote> <p>You're in luck. The DBD::SQLite driver supplies a <code>table_info</code> extension field <code>'sqlite_sql'</code>, which for me gives the "CREATE TABLE ..." statements behind each table. (Also what I get from .schema.) Try:</p> <pre><code>my $sth = $dbh-&gt;table_info('', 'main', '%', 'TABLE'); while (my $r = $sth-&gt;fetchrow_hashref) { say $r-&gt;{sqlite_sql}; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload