I don’t know why but the SQLColumnSchema class of the SQLite API does not return the DEFAULT value of a field, neither its UNIQUE attribute. This kind of information is needed when you have to explore the schema of your AIR database. Here is my solution.
The SQLite API that is provided by AIR has a very interesting and powerful feature: the loadSchema() method that returns the whole structure of a SQLite database as a SQLSchemaResult class.
The structure of the SQLSchemaResult can be illustrated by the following schema.
This class is composed by 4 arrays: tables containing SQLTableSchema classes, views containing SQLViewSchemas, triggers for SQTriggerSchema and indices for SQLIndicesSchema.
SQLTableSchema and SQLViewSchema contain an array of SQLColumnSchema classes. Each SQLColumnSchema represents the fields in the tables (or views) of the database. This last class has properties as names, allowNull, primaryKey, dataType… that describes the field in the SQLite database.
As I am working on an AIR application that needs to analyze the structure of SQLite databases, I decided to convert the SQLSchemaResult to XML and then play with it. I think that it is really easier to perform the task that the application has to execute (the easiest way being the use of the HierarchicalData class but…).