Views & indexes
A view names a stored query. An index helps some lookups but costs storage and slows writes. Use EXPLAIN QUERY PLAN in SQLite to inspect the chosen plan. Indexes do not guarantee a query will use them.
हिन्दी में समझें
व्यू संग्रहीत क्वेरी का नाम है। इंडेक्स कुछ खोज तेज करता है, पर जगह और लिखने का समय लेता है। SQLite में EXPLAIN QUERY PLAN से योजना देखें।
अभ्यास: Books उत्पाद के name,price वाला book_prices व्यू बनाएँ। व्यू को price क्रम में पढ़ें।
Hinglish mein samjhein
View stored query ka naam hai. Index kuch lookups fast karta hai par storage aur write cost badhata hai. SQLite EXPLAIN QUERY PLAN se chosen plan dekho.
Practice: Books products name,price ka book_prices view banao; view price sorted query karo.
A small SQL example
CREATE INDEX idx_orders_customer ON orders(customer_id);
EXPLAIN QUERY PLAN SELECT * FROM orders WHERE customer_id=1;Examples use the fictional shop database bundled with the SQL playground: customers, products, orders, order_items and employees. The engine is SQLite; other SQL dialects may differ.
Try this example in the SQL playground →Practise this idea
Create a view book_prices selecting name,price for Books products. Query the view ordered by price.
Check answer & explanation
CREATE VIEW book_prices AS SELECT name,price FROM products WHERE category='Books'; SELECT * FROM book_prices ORDER BY price;CREATE VIEW names a query that filters Books products. Querying that view returns the current underlying data, ordered by price.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
An index has a cost in…
Check the quiz answer
Storage and writes
A view names a stored query. An index helps some lookups but costs storage and slows writes. Use EXPLAIN QUERY PLAN in SQLite to inspect the chosen plan. Indexes do not guarantee a query will use them.
References & corrections
Use the official SQLite documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.