Interested in improving this site? Please check the To Do page.

Back to SQLite Verbs

sqlite.tableExists

Determine if the named table exists in the database.

Syntax

sqlite.tableExists (dbID, tableName)

Params

dbID is the database ID returned by sqlite.open. tableName is the name of a table.

Returns

True if the table exists, false if not.

Examples

on getTableSchema (dbID, table) {
	«Specialized query that returns a list of tables in a database using sqlite_master
	«special database query
	local (compiledQuery, query, result, schema);
	if not sqlite.tableExists(dbID, table) {
		scriptError("sqlite.getTableSchema requires the named table to be defined in the database.")};
	query = "select sql from sqlite_master where name='" + table + "'";
	compiledQuery = sqlite.compileQuery(dbID, query);
	result = sqlite.stepQuery(compiledQuery);
	schema = sqlite.getColumnText(compiledQuery, 1);
	sqlite.clearQuery(compiledQuery);
	return schema}

Notes

sqlite.tableExists takes advantage of the table sqlite_master defined in all SQLite tables. sqlite_master contains all sorts of interesting information that may be useful to understanding the database definition.

See Also


Personal Tools