Database / SQLite Interview questions
What is the difference between CHAR, VARCHAR, and TEXT in SQLite?
Functionally, all three are treated identically in SQLite — whatever length or width you declare
(CHAR(10), VARCHAR(255)) is completely ignored for storage purposes; SQLite stores
the string exactly as given, taking only as much space as the actual text requires, since it uses dynamic
typing rather than fixed-width storage.
CREATE TABLE t ( a CHAR(10), b VARCHAR(255), c TEXT ); INSERT INTO t VALUES ('hi', 'this text is way longer than expected', 'anything'); -- all three succeed with no truncation or padding; SQLite doesn't enforce the declared length
All three simply map to the TEXT storage class and affinity underneath. The length/width
number in CHAR(10) or VARCHAR(255) is accepted syntactically (for compatibility
with SQL written for other databases) but has zero effect on how SQLite actually stores or validates the
value.
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...
