1.Dd March 11, 2017 2.Dt SQLITE3_TABLE_COLUMN_METADATA 3 3.Os 4.Sh NAME 5.Nm sqlite3_table_column_metadata 6.Nd Extract Metadata About A Column Of A Table 7.Sh SYNOPSIS 8.Ft int 9.Fo sqlite3_table_column_metadata 10.Fa "sqlite3 *db" 11.Fa "const char *zDbName" 12.Fa "const char *zTableName" 13.Fa "const char *zColumnName" 14.Fa "char const **pzDataType" 15.Fa "char const **pzCollSeq" 16.Fa "int *pNotNull" 17.Fa "int *pPrimaryKey" 18.Fa "int *pAutoinc " 19.Fc 20.Sh DESCRIPTION 21The sqlite3_table_column_metadata(X,D,T,C,....) routine returns information 22about column C of table T in database D on database connection 23X. 24The sqlite3_table_column_metadata() interface returns SQLITE_OK and 25fills in the non-NULL pointers in the final five arguments with appropriate 26values if the specified column exists. 27The sqlite3_table_column_metadata() interface returns SQLITE_ERROR 28and if the specified column does not exist. 29If the column-name parameter to sqlite3_table_column_metadata() is 30a NULL pointer, then this routine simply checks for the existence of 31the table and returns SQLITE_OK if the table exists and SQLITE_ERROR 32if it does not. 33.Pp 34The column is identified by the second, third and fourth parameters 35to this function. 36The second parameter is either the name of the database (i.e. 37"main", "temp", or an attached database) containing the specified table 38or NULL. 39If it is NULL, then all attached databases are searched for the table 40using the same algorithm used by the database engine to resolve unqualified 41table references. 42.Pp 43The third and fourth parameters to this function are the table and 44column name of the desired column, respectively. 45.Pp 46Metadata is returned by writing to the memory locations passed as the 475th and subsequent parameters to this function. 48Any of these arguments may be NULL, in which case the corresponding 49element of metadata is omitted. 50.Bd -ragged 51<table border="1"> <tr><th> Parameter <th> Output<br>Type <th> Description 52.Pp 53<tr><td> 5th <td> const char* <td> Data type <tr><td> 6th <td> const 54char* <td> Name of default collation sequence <tr><td> 7th <td> int 55<td> True if column has a NOT NULL constraint <tr><td> 8th <td> int 56<td> True if column is part of the PRIMARY KEY <tr><td> 9th <td> int 57<td> True if column is AUTOINCREMENT </table> 58.Ed 59.Pp 60The memory pointed to by the character pointers returned for the declaration 61type and collation sequence is valid until the next call to any SQLite 62API function. 63.Pp 64If the specified table is actually a view, an error code 65is returned. 66.Pp 67If the specified column is "rowid", "oid" or "_rowid_" and the table 68is not a WITHOUT ROWID table and an INTEGER PRIMARY KEY 69column has been explicitly declared, then the output parameters are 70set for the explicitly declared column. 71If there is no INTEGER PRIMARY KEY column, then 72the outputs for the rowid are set as follows: 73.Bd -literal 74data type: "INTEGER" collation sequence: "BINARY" not null: 0 primary 75key: 1 auto increment: 0 76.Ed 77.Pp 78This function causes all database schemas to be read from disk and 79parsed, if that has not already been done, and returns an error if 80any errors are encountered while loading the schema. 81.Sh SEE ALSO 82.Xr sqlite3 3 83