Re: [sqlite] SQLite Introspection

2010-12-07 Thread BareFeetWare
On 07/12/2010, at 11:25 AM, Tom Krehbiel wrote:

> I haven't been able to find anything in the documentation that indicates how 
> to get at the trigger definition.

You can, of course, get the definition of any entity from the SQLite_Master 
table, such as:

select Name, SQL from SQLite_Master where Type = 'trigger' and Tbl_Name = 'My 
Table';

to get the Name and SQL of all triggers for a particular table (or view).

But there's no provided way to parse the trigger definition into its parameters 
(eg instead of|before|after, update of|update|delete|insert, steps).

Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite Introspection

2010-12-07 Thread Jay A. Kreibich
On Mon, Dec 06, 2010 at 05:25:43PM -0700, Tom Krehbiel scratched on the wall:

> The documentation for the analyze
> command says they can do a *select *on table *sqlite_stat1 *but when I do a
> select I get an error with 'no such table: sqlite_stat1'.

  Like the table sqlite_sequence (used for AUTOINCREMENT), the
  sqlite_statN tables are not created until they're needed.  You need to
  actually run the ANALYZE command at least once to create the
  sqlite_statN tables.

  Also, there can be more than one.  If SQLite is compiled with the
  SQLITE_ENABLE_STAT2 option, there will also be an sqlite_stat2 table,
  to go along with the sqlite_stat1 table.  In the future there may be
  more.

> I haven't been able to find anything in the documentation that
> indicates how to get at the trigger definition.

  They are in the sqlite_master table, just like everything else.  As
  far as I know, there is no trigger equivilant of PRAGMA table_info()
  or PRAGMA index_info().

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users