> -----Original Message----- > From: Marco Bambini [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 13, 2006 2:38 PM > To: sqlite-users@sqlite.org > Subject: [sqlite] PRAGMA table_info > > Using PRAGMA table_info(...) there is no way to know if a > column is declared as unique and/or autoincrement. > Am I missing something? > > Is there a way to get these info? You'll have to run a few hoops to get this information.
First you can prepare a "SELECT * FROM <table>" statement, then call sqlite3_table_column_metadata to get primary key and autoincrement information about the column(s) in the statement. To get uniqueness, it's a little more convoluted. First, if the column is of type "integer" and is a primary key, and is the only primary key in a table, then it is also implied to be unique. In such a case, no real index is created (it's a rowid), so you can't find that information out by looking in the indexes. Once you've eliminated the rowids, you'll have to look through all the indexes to find out if the given column is in a given index. If the index is a unique index, and has only one column, then that column is unique. I think that covers all the cases ... Robert