1.Dd January 24, 2024 2.Dt SQLITE3_COLUMN_DATABASE_NAME 3 3.Os 4.Sh NAME 5.Nm sqlite3_column_database_name , 6.Nm sqlite3_column_database_name16 , 7.Nm sqlite3_column_table_name , 8.Nm sqlite3_column_table_name16 , 9.Nm sqlite3_column_origin_name , 10.Nm sqlite3_column_origin_name16 11.Nd source of data in a query result 12.Sh SYNOPSIS 13.In sqlite3.h 14.Ft const char * 15.Fo sqlite3_column_database_name 16.Fa "sqlite3_stmt*" 17.Fa "int" 18.Fc 19.Ft const void * 20.Fo sqlite3_column_database_name16 21.Fa "sqlite3_stmt*" 22.Fa "int" 23.Fc 24.Ft const char * 25.Fo sqlite3_column_table_name 26.Fa "sqlite3_stmt*" 27.Fa "int" 28.Fc 29.Ft const void * 30.Fo sqlite3_column_table_name16 31.Fa "sqlite3_stmt*" 32.Fa "int" 33.Fc 34.Ft const char * 35.Fo sqlite3_column_origin_name 36.Fa "sqlite3_stmt*" 37.Fa "int" 38.Fc 39.Ft const void * 40.Fo sqlite3_column_origin_name16 41.Fa "sqlite3_stmt*" 42.Fa "int" 43.Fc 44.Sh DESCRIPTION 45These routines provide a means to determine the database, table, and 46table column that is the origin of a particular result column in SELECT 47statement. 48The name of the database or table or column can be returned as either 49a UTF-8 or UTF-16 string. 50The _database_ routines return the database name, the _table_ routines 51return the table name, and the origin_ routines return the column name. 52The returned string is valid until the prepared statement 53is destroyed using 54.Fn sqlite3_finalize 55or until the statement is automatically reprepared by the first call 56to 57.Fn sqlite3_step 58for a particular run or until the same information is requested again 59in a different encoding. 60.Pp 61The names returned are the original un-aliased names of the database, 62table, and column. 63.Pp 64The first argument to these interfaces is a prepared statement. 65These functions return information about the Nth result column returned 66by the statement, where N is the second function argument. 67The left-most column is column 0 for these routines. 68.Pp 69If the Nth column returned by the statement is an expression or subquery 70and is not a column value, then all of these functions return NULL. 71These routines might also return NULL if a memory allocation error 72occurs. 73Otherwise, they return the name of the attached database, table, or 74column that query result column was extracted from. 75.Pp 76As with all other SQLite APIs, those whose names end with "16" return 77UTF-16 encoded strings and the other functions return UTF-8. 78.Pp 79These APIs are only available if the library was compiled with the 80SQLITE_ENABLE_COLUMN_METADATA C-preprocessor 81symbol. 82.Pp 83If two or more threads call one or more column metadata interfaces 84for the same prepared statement and result column 85at the same time then the results are undefined. 86.Sh IMPLEMENTATION NOTES 87These declarations were extracted from the 88interface documentation at line 4822. 89.Bd -literal 90SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); 91SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); 92SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); 93SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); 94SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); 95SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); 96.Ed 97.Sh SEE ALSO 98.Xr sqlite3_finalize 3 , 99.Xr sqlite3_step 3 , 100.Xr sqlite3_stmt 3 101