Database / SQLite Interview questions
What is dynamic typing (type affinity) in SQLite?
SQLite uses type affinity rather than strict column typing: a column's declared type is a preference for how to store a value, not a hard constraint that rejects mismatched data the way most databases enforce. Each column is assigned one of five affinities (TEXT, NUMERIC, INTEGER, REAL, BLOB) based on keywords in its declared type, and SQLite tries to convert an inserted value to match that affinity, but will still store the value as-is if conversion isn't sensible.
CREATE TABLE t (a INTEGER); INSERT INTO t VALUES ('hello'); -- succeeds! 'hello' has no numeric form, so it's stored as TEXT
This flexibility is a deliberate design choice for SQLite's typical embedded use cases, but it's also a common surprise for developers coming from strictly-typed databases, who expect a type mismatch to raise an error rather than being silently accepted and stored in its original form.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
