Database / LanceDB Interview questions
How do you create a table in LanceDB?
Creating a table in LanceDB typically means connecting to a database directory (local or object storage), then calling a create method with either an initial batch of data or an explicit schema.
import lancedb from lancedb.pydantic import LanceModel, Vector db = lancedb.connect("./my_lancedb") class Document(LanceModel): text: str vector: Vector(384) table = db.create_table("documents", schema=Document) table.add([{"text": "hello", "vector": [0.1] * 384}])
The schema can be defined explicitly (as shown above using a Pydantic-based LanceModel, which maps cleanly to Arrow types under the hood), or inferred automatically by passing an initial list of dictionaries or a Pandas DataFrame directly to create_table, letting LanceDB determine column types from the data itself.
The mode parameter (commonly "create", "overwrite", or "append"-like semantics via subsequent add calls) controls what happens if a table with that name already exists, which matters in scripts or notebooks that might be re-run against the same database directory multiple times during development.
More Related questions...