Queries the SQLite system catalog to retrieve all user-created tables in the database. This is useful for schema inspection, validation, and debugging purposes.
The D1 database instance to inspect
Promise resolving to array of table names, sorted alphabetically
Returns empty array if query fails or database is inaccessible
const tables = await listTables(env.DB_EAST);console.log('Available tables:', tables);// Output: ['posts', 'shard_mappings', 'users']// Check for specific tableif (tables.includes('users')) { console.log('Users table exists');} Copy
const tables = await listTables(env.DB_EAST);console.log('Available tables:', tables);// Output: ['posts', 'shard_mappings', 'users']// Check for specific tableif (tables.includes('users')) { console.log('Users table exists');}
Queries the SQLite system catalog to retrieve all user-created tables in the database. This is useful for schema inspection, validation, and debugging purposes.