Firman Wandayandi wrote:
Hi,

Is any possible way to know if a column is UNIQUE without "PRAGMA
index_info('<index_name>')"? Seems "PRAGMA table_info('<table_name>')"
doesn't returns the unique flag of column.

Thanks for advice.
Firman,

You should try pragma index_list('<table_name>'). It returns a list of all the indexes (or indices) on the specified table. It provides a flag for each unique index as well as the index names. You can then get the details about the number, and order of the columns in the index using pragma index_info.

Here is a short sample session with the sqlite shell.

   SQLite version 3.3.8
   Enter ".help" for instructions
   sqlite> create table t (a integer primary key, b text unique);
   sqlite> .header on
   sqlite> .mode column
   sqlite> pragma table_info('t');
   cid         name        type        notnull     dflt_value  pk
   ----------  ----------  ----------  ----------  ----------  ----------
   0           a           integer     0                       1
   1           b           text        0                       0
   sqlite> pragma index_list('t');
   seq         name                  unique
   ----------  --------------------  ----------
   0           sqlite_autoindex_t_1  1
   sqlite> pragma index_info('sqlite_autoindex_t_1');
   seqno       cid         name
   ----------  ----------  ----------
   0           1           b

HTH
Dennis Cote

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to