Small. Fast. Reliable.
Choose any three.
*** 2,14 ****
  <H1>Information Schema</h1>
  
  <p>If you have question regarding this information or if I have something wrong please email me at vbsqliteNOSPAM@NOSPAMag-software.com (remove the NOSPAM's)<p>
! The information schema consists of a set of views that contain information about the objects defined in the current database. The information schema is defined in the SQL standard and can therefore be expected to be portable and remain stable.</p>
  
- <b>SQLite_Master</b> is the base table where schema information is stored, these views query this table<p>
- SQLite doesn't support the idea of different owners of objects so the naming convention for the INFORMATION_SCHEMA views are <br>INFORMATION_SCHEMA_<b>OBJECTNAME</b><p>
- <br>
- <b><font size=3>Information_Schema_TABLES</font></b><br>
- The view TABLES contains all tables and views defined in the current database<p>
  <pre>
  CREATE VIEW INFORMATION_SCHEMA_TABLES AS
      SELECT * FROM (
--- 2,44 ----
  <H1>Information Schema</h1>
  
  <p>If you have question regarding this information or if I have something wrong please email me at vbsqliteNOSPAM@NOSPAMag-software.com (remove the NOSPAM's)<p>
! The information schema consists of a set of views that contain information about the objects defined in the current database. The information schema is defined in the SQL standard and can therefore be expected to be portable and remain stable.  (Compare PostgreSQL's <a href="http://www.postgresql.org/docs/current/static/information-schema.html">information schema documentation</a>.)</p>
! 
! <p><b>sqlite_master</b> is the base table where schema information is stored, these views query this table.  SQLite doesn't support the idea of different owners of objects so the naming convention for the INFORMATION_SCHEMA views are INFORMATION_SCHEMA_<b>OBJECTNAME</b>.</p>
! 
! <h2>INFORMATION_SCHEMA_TABLES</h2>
! <p>This view describes all tables and views defined in the current database.  It has these columns:</p>
! 
! <table border="1">
!   <tr>
!     <th>Name</th>
!     <th>Description</th>
!   </tr>
!   <tr>
!     <td>TABLE_CATALOG</td>
!     <td>Name of the database that contains the table (always 'main')</td>
!   </tr>
!   <tr>
!     <td>TABLE_SCHEMA</td>
!     <td>Name of the schema that contains the table (always 'sqlite')</td>
!   </tr>
!   <tr>
!     <td>TABLE_NAME</td>
!     <td>Name of the table or view</td>
!   </tr>
!   <tr>
!     <td>TABLE_TYPE</td>
!     <td>Type of the table: BASE TABLE for a persistent
!     base table (the normal table type), BASE VIEW for a
!     view, or  TEMPORARY TABLE for a temporary table and TEMPORARY VIEW for a
!     temporary view.</td>
!   </tr>
!   <tr>
!     <td>TABLE_SOURCE</td>
!     <td>The SQL script with which the object was created.</td>
!   </tr>
! </table>
  
  <pre>
  CREATE VIEW INFORMATION_SCHEMA_TABLES AS
      SELECT * FROM (
***************
*** 36,71 ****
      ) ORDER BY TABLE_TYPE, TABLE_NAME;
  </pre>
  
! <b>Columns Description</b><br>
! <table border="1" cellspacing="0" cellpadding="0"  >
!   <tr>
!     <td><b>Name</b></td>
!     <td><b>Description</b></td>
!   </tr>
!   <tr>
!     <td>table_catalog</td>
!     <td>Name of the database that contains the table (always the main)</td>
!   </tr>
!   <tr>
!     <td>table_schema</td>
!     <td>Name of the schema that contains the table</td>
!   </tr>
!   <tr>
!     <td>table_name</td>
!     <td>Name of the table or View</td>
!   </tr>
!   <tr>
!     <td>table_type</td>
!     <td>Type of the table: BASE TABLE for a persistent
!     base table (the normal table type), BASE VIEW for a
!     view, or  TEMPORARY TABLE for a temporary table and TEMPORARY VIEW for a
!     temporary view.</td>
!   </tr>
!   <tr>
!     <td>table_source</td>
!     <td>The SQL script with which the object was created.</td>
!   </tr>
! </table>
  
! <p>(Compare PostgreSQL's <a href='http://www.postgresql.org/docs/current/static/information-schema.html'>information schema documentation</a>.)</p>
  </html>
--- 66,86 ----
      ) ORDER BY TABLE_TYPE, TABLE_NAME;
  </pre>
  
! <hr>
! <p><b>Note, 12 Jan 2006:</b> I reformatted this page so it was actually possible to read it, but I did not debug the SQL code given.  As stated, it does not work; any query on the view gives the error "no such table: sqlite_temp_master".  If you don't use temporary tables you can just rip out the second inner SELECT (which then renders the outer SELECT unnecessary):</p>
  
! <pre>
! CREATE VIEW INFORMATION_SCHEMA_TABLES AS
!     SELECT 'main'     AS TABLE_CATALOG,
!            'sqlite'   AS TABLE_SCHEMA,
!            tbl_name   AS TABLE_NAME,
!            CASE WHEN type = 'table' THEN 'BASE TABLE'
!                 WHEN type = 'view'  THEN 'VIEW'
!            END        AS TABLE_TYPE,
!            sql        AS TABLE_SOURCE
!     FROM   sqlite_master
!     WHERE  type IN ('table', 'view')
!            AND tbl_name NOT LIKE 'INFORMATION_SCHEMA_%'
!     ORDER BY TABLE_TYPE, TABLE_NAME;
! </pre>
  </html>