Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is a correct way to do so. (Just puzzled by the "[]" braces around your table names -- these are most probably not part of the actual names, so need to be removed)</p> <p>Moreover, it is an efficient way: since you are providing a constant for both <code>table_schema</code> as well as for <code>table_name</code>, you are therefore utilizing <a href="http://dev.mysql.com/doc/refman/5.1/en/information-schema-optimization.html" rel="nofollow">INFORMATION_SCHEMA optimizations</a>, in that the table is not even opened:</p> <pre><code>explain select count(*) from information_schema.tables where table_schema='world' and table_name='City'; +----+-------------+--------+------+---------------+-------------------------+---------+------+------+---------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+--------+------+---------------+-------------------------+---------+------+------+---------------------------------------------------+ | 1 | SIMPLE | tables | ALL | NULL | TABLE_SCHEMA,TABLE_NAME | NULL | NULL | NULL | Using where; Skip_open_table; Scanned 0 databases | +----+-------------+--------+------+---------------+-------------------------+---------+------+------+---------------------------------------------------+ </code></pre> <p>The "SHOW TABLES" solution offered is good, too -- and practically the same as far as Java/Python/Whatever code goes. The result is a valid ResultSet:</p> <pre><code>SHOW TABLES FROM world LIKE 'City'; +------------------------+ | Tables_in_world (City) | +------------------------+ | City | +------------------------+ </code></pre> <p>But to just complete the story: it is not a standard SQL syntax - so if you're using some framework like an ORM of some sorts, you may not always be able to get by with this type of query (as I recall EJB3 will not let you do so).</p> <p>Also, it is very difficult to parse on server side, see: <a href="http://code.openark.org/blog/mysql/reading-results-of-show-statements-on-server-side" rel="nofollow">Reading results of SHOW statements, on server side</a>, though this may not be a concern to you.</p>
 

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