SQL Views and Materialized Views
How SQL views work: saving queries under a name, querying and joining views, updatable views and WITH CHECK OPTION, how views depend on tables, using views for security and stable interfaces, and materialized views that store results and need refreshing.
kvi5hnuCode Sprout team member10 min readOn this page
A query that's useful once is often useful again: the customer summary that three reports need, the join that every dashboard repeats, the subset of columns that a team is allowed to see. A view gives a query a name, so it can be used like a table. A materialized view goes further and stores the query's result, trading freshness for speed.
This article covers creating and querying views, changing data through them, how they depend on their tables, what they're good for, and when a materialized view is the better choice.
Creating and querying a view
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
category VARCHAR(20) NOT NULL,
brand VARCHAR(20),
price DECIMAL(8, 2) NOT NULL,
stock INTEGER NOT NULL,
weight_g INTEGER
);
INSERT INTO products VALUES
(1, 'Ridge 2 tent', 'tents', 'Alpina', 249.99, 12, 2100),
(2, 'Summit 4 tent', 'tents', 'Alpina', 489.00, 3, 4300),
(3, 'Glow head torch', 'lighting', 'Lumen', 34.50, 40, 90),
(4, 'Basecamp lantern', 'lighting', NULL, 27.00, 15, NULL),
(5, 'Trail 30 backpack', 'packs', 'Kestrel', 89.95, 22, 1150),
(6, 'Day 18 backpack', 'packs', 'Kestrel', 54.00, 0, 640),
(7, 'Merino socks', 'clothing', 'Woolly', 16.00, 75, 80);
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
city VARCHAR(30),
referred_by INTEGER REFERENCES customers (customer_id)
);
INSERT INTO customers VALUES
(1, 'Asha Rao', 'Pune', NULL),
(2, 'Ben Okafor', 'Leeds', 1),
(3, 'Chen Wei', 'Pune', 1),
(4, 'Dana Cruz', 'York', 2),
(5, 'Eli Novak', 'Leeds', NULL),
(6, 'Farah Haddad', NULL, 3);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers (customer_id), -- NULL = guest checkout
placed_on DATE NOT NULL,
status VARCHAR(10) NOT NULL
);
INSERT INTO orders VALUES
(101, 1, DATE '2026-03-02', 'shipped'),
(102, 2, DATE '2026-03-05', 'shipped'),
(103, 1, DATE '2026-03-09', 'delivered'),
(104, 3, DATE '2026-03-15', 'pending'),
(105, 4, DATE '2026-03-20', 'cancelled'),
(106, NULL, DATE '2026-03-22', 'shipped');
CREATE TABLE order_items (
order_id INTEGER REFERENCES orders (order_id),
product_id INTEGER REFERENCES products (product_id),
qty INTEGER NOT NULL,
unit_price DECIMAL(8, 2) NOT NULL,
PRIMARY KEY (order_id, product_id)
);
INSERT INTO order_items VALUES
(101, 1, 1, 249.99), (101, 7, 3, 16.00),
(102, 3, 2, 34.50),
(103, 5, 1, 89.95), (103, 3, 1, 34.50), (103, 7, 2, 15.00),
(104, 2, 1, 489.00),
(105, 6, 1, 54.00),
(106, 7, 1, 16.00);
-- A view is a stored query with a name
CREATE VIEW customer_summary AS
SELECT c.customer_id, c.name, c.city,
COUNT(o.order_id) AS orders,
COALESCE(SUM(oi.qty * oi.unit_price), 0) AS spent
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.customer_id AND o.status <> 'cancelled'
LEFT JOIN order_items oi ON oi.order_id = o.order_id
GROUP BY c.customer_id, c.name, c.city;
-- Query it like a table: filter, sort, join
SELECT name, city, spent
FROM customer_summary
WHERE spent > 0
ORDER BY spent DESC;
-- A view stores no data: changes to the base tables show up immediately
INSERT INTO orders VALUES (107, 5, DATE '2026-03-25', 'pending');
INSERT INTO order_items VALUES (107, 2, 1, 489.00);
SELECT name, spent FROM customer_summary WHERE customer_id = 5;
name | city | spent
------------+-------+--------
Chen Wei | Pune | 489.00
Asha Rao | Pune | 452.44
Ben Okafor | Leeds | 69.00
(3 rows)
name | spent
-----------+--------
Eli Novak | 489.00
(1 row)
CREATE VIEW name AS SELECT ... stores the query, not its result. After that, the view can be used anywhere a table can: in FROM, joined to other tables, filtered, sorted, and grouped. The query above treats customer_summary as if it were a table with spent as a column.
Because a view stores no data, it always shows the current state of its tables. When Eli places an order, the very next query of the view includes it, with no refresh.
When a query uses a view, the database substitutes the view's query into it, then plans the whole thing as one query. A condition such as WHERE customer_id = 5 is usually pushed down into the view's query, so the database doesn't compute the summary for every customer and then discard all but one. Views are therefore no slower than writing the same query out by hand, with one caution: a view that does far more work than a particular query needs, such as joining tables whose columns that query never reads, can make that query slower than a targeted one. PostgreSQL can't always skip unneeded joins.
What views are good for
- Reuse. Write a complex join or calculation once, test it, and use it everywhere. A bug fix in the view fixes every query that uses it.
- Simplicity. Report writers and analysts query
customer_summaryinstead of rewriting three-table joins with the right join conditions and the cancelled-order rule. - A stable interface. Applications can query views instead of tables, so the tables can be reorganised, for example split or renamed during a migration (article 53), while the view keeps presenting the old shape.
- Security. Grant access to a view without granting access to its tables (article 58), so users see only certain columns, such as no salaries, or certain rows, such as only their own region.
Views have limits: they can't take parameters (use a function, article 64, for that), and stacking views on views on views makes queries hard to understand and to tune. Keep the layers shallow.
Changing data through a view
A view over a single table, without aggregates, DISTINCT, GROUP BY, set operations or window functions, is automatically updatable in PostgreSQL, MySQL, SQL Server and Oracle: INSERT, UPDATE and DELETE on the view change the base table. The examples use a small gear table with two lighting items and a tent:
CREATE TABLE gear (
gear_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
category TEXT NOT NULL DEFAULT 'misc',
price DECIMAL(8, 2) NOT NULL
);
INSERT INTO gear VALUES (1, 'Glow head torch', 'lighting', 34.50), (2, 'Basecamp lantern', 'lighting', 27.00), (3, 'Ridge 2 tent', 'tents', 249.99);
-- A simple view over one table is updatable: changes go through to the base table
CREATE VIEW lighting AS
SELECT gear_id, name, price FROM gear
WHERE category = 'lighting';
UPDATE lighting SET price = 29.00 WHERE gear_id = 2;
-- Without CHECK OPTION, an insert through the view can create a row the view can't see
INSERT INTO lighting (gear_id, name, price) VALUES (4, 'Fire steel', 12.00);
SELECT gear_id, name FROM lighting ORDER BY gear_id;
SELECT gear_id, name, category, price FROM gear ORDER BY gear_id;
gear_id | name
---------+------------------
1 | Glow head torch
2 | Basecamp lantern
(2 rows)
gear_id | name | category | price
---------+------------------+----------+--------
1 | Glow head torch | lighting | 34.50
2 | Basecamp lantern | lighting | 29.00
3 | Ridge 2 tent | tents | 249.99
4 | Fire steel | misc | 12.00
(4 rows)
The UPDATE through lighting changed the lantern's price in gear. The INSERT worked too, but the new row got the default category, 'misc', because the view doesn't include the category column. So the Fire steel row exists in the table but isn't visible through the view that created it.
WITH CHECK OPTION prevents that. It rejects any insert or update through the view that would produce a row the view can't see:
CREATE TABLE gear (
gear_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
category TEXT NOT NULL DEFAULT 'misc',
price DECIMAL(8, 2) NOT NULL
);
INSERT INTO gear VALUES (1, 'Glow head torch', 'lighting', 34.50), (2, 'Basecamp lantern', 'lighting', 27.00), (3, 'Ridge 2 tent', 'tents', 249.99);
-- WITH CHECK OPTION rejects changes that would fall outside the view
CREATE VIEW lighting_checked AS
SELECT gear_id, name, category, price FROM gear
WHERE category = 'lighting'
WITH CHECK OPTION;
INSERT INTO lighting_checked VALUES (5, 'Lantern mantle', 'lighting', 3.50);
INSERT INTO lighting_checked (gear_id, name, price) VALUES (6, 'Fire steel', 12.00);
UPDATE lighting_checked SET category = 'tents' WHERE gear_id = 1;
SELECT gear_id, name, category FROM gear ORDER BY gear_id;
psql:/workspace/solution.sql:16: ERROR: new row violates check option for view "lighting_checked"
DETAIL: Failing row contains (6, Fire steel, misc, 12.00).
psql:/workspace/solution.sql:17: ERROR: new row violates check option for view "lighting_checked"
DETAIL: Failing row contains (1, Glow head torch, tents, 34.50).
gear_id | name | category
---------+------------------+----------
1 | Glow head torch | lighting
2 | Basecamp lantern | lighting
3 | Ridge 2 tent | tents
5 | Lantern mantle | lighting
(4 rows)
The lantern mantle, a lighting item, is accepted. The Fire steel insert is rejected because its category would be 'misc', and the update that would move the head torch into 'tents' is rejected too. A view with WITH CHECK OPTION that filters rows by region or by owner guarantees that users can only write rows they're allowed to see.
Views that aggregate can't be updated, because the database can't tell which base rows a change should affect. Views that join tables can't be updated automatically in PostgreSQL. MySQL, SQL Server and Oracle (for key-preserved tables) allow changes through a join view when they touch only one base table. PostgreSQL lets you define what should happen with an INSTEAD OF trigger on the view (article 65), and SQL Server and Oracle support those too.
Views depend on their tables
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
category VARCHAR(20) NOT NULL,
brand VARCHAR(20),
price DECIMAL(8, 2) NOT NULL,
stock INTEGER NOT NULL,
weight_g INTEGER
);
INSERT INTO products VALUES
(1, 'Ridge 2 tent', 'tents', 'Alpina', 249.99, 12, 2100),
(2, 'Summit 4 tent', 'tents', 'Alpina', 489.00, 3, 4300),
(3, 'Glow head torch', 'lighting', 'Lumen', 34.50, 40, 90),
(4, 'Basecamp lantern', 'lighting', NULL, 27.00, 15, NULL),
(5, 'Trail 30 backpack', 'packs', 'Kestrel', 89.95, 22, 1150),
(6, 'Day 18 backpack', 'packs', 'Kestrel', 54.00, 0, 640),
(7, 'Merino socks', 'clothing', 'Woolly', 16.00, 75, 80);
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
city VARCHAR(30),
referred_by INTEGER REFERENCES customers (customer_id)
);
INSERT INTO customers VALUES
(1, 'Asha Rao', 'Pune', NULL),
(2, 'Ben Okafor', 'Leeds', 1),
(3, 'Chen Wei', 'Pune', 1),
(4, 'Dana Cruz', 'York', 2),
(5, 'Eli Novak', 'Leeds', NULL),
(6, 'Farah Haddad', NULL, 3);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers (customer_id), -- NULL = guest checkout
placed_on DATE NOT NULL,
status VARCHAR(10) NOT NULL
);
INSERT INTO orders VALUES
(101, 1, DATE '2026-03-02', 'shipped'),
(102, 2, DATE '2026-03-05', 'shipped'),
(103, 1, DATE '2026-03-09', 'delivered'),
(104, 3, DATE '2026-03-15', 'pending'),
(105, 4, DATE '2026-03-20', 'cancelled'),
(106, NULL, DATE '2026-03-22', 'shipped');
CREATE TABLE order_items (
order_id INTEGER REFERENCES orders (order_id),
product_id INTEGER REFERENCES products (product_id),
qty INTEGER NOT NULL,
unit_price DECIMAL(8, 2) NOT NULL,
PRIMARY KEY (order_id, product_id)
);
INSERT INTO order_items VALUES
(101, 1, 1, 249.99), (101, 7, 3, 16.00),
(102, 3, 2, 34.50),
(103, 5, 1, 89.95), (103, 3, 1, 34.50), (103, 7, 2, 15.00),
(104, 2, 1, 489.00),
(105, 6, 1, 54.00),
(106, 7, 1, 16.00);
-- Views depend on their tables: changes that would break a view are refused
CREATE VIEW product_list AS
SELECT product_id, name, price FROM products;
ALTER TABLE products DROP COLUMN price;
-- CREATE OR REPLACE VIEW may add columns at the end, but not remove or reorder them
CREATE OR REPLACE VIEW product_list AS
SELECT product_id, name, price, category FROM products;
CREATE OR REPLACE VIEW product_list AS
SELECT product_id, price FROM products;
SELECT * FROM product_list WHERE product_id = 1;
psql:/workspace/solution.sql:66: ERROR: cannot drop column price of table products because other objects depend on it
DETAIL: view product_list depends on column price of table products
HINT: Use DROP ... CASCADE to drop the dependent objects too.
psql:/workspace/solution.sql:72: ERROR: cannot drop columns from view
product_id | name | price | category
------------+--------------+--------+----------
1 | Ridge 2 tent | 249.99 | tents
(1 row)
The database records which tables and columns each view uses:
- Dropping the
pricecolumn fails, becauseproduct_listdepends on it. The error names the view.CASCADEwould drop the view too (article 53). CREATE OR REPLACE VIEWchanges a view's query without dropping it, which keeps its permissions and the objects that depend on it. In PostgreSQL, the new query must produce the same columns with the same names and types, in the same order, and may only add new columns at the end. Addingcategoryworks, but removingnamefails with "cannot drop columns from view". To change a view's columns in other ways, drop and recreate it.
In PostgreSQL, a view's columns are fixed when it's created: SELECT * in a view is expanded into the column list at that moment, so columns added to the table later don't appear in the view. List the columns explicitly in views, to make that obvious. Other databases differ: MySQL and SQL Server don't stop you dropping a column a view uses, and the view fails when it's next queried. SQL Server's WITH SCHEMABINDING adds protection like PostgreSQL's.
Materialized views

A view runs its query every time. When that query is expensive, such as aggregating millions of rows for a dashboard that refreshes every few seconds, a materialized view stores the result instead:
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
category VARCHAR(20) NOT NULL,
brand VARCHAR(20),
price DECIMAL(8, 2) NOT NULL,
stock INTEGER NOT NULL,
weight_g INTEGER
);
INSERT INTO products VALUES
(1, 'Ridge 2 tent', 'tents', 'Alpina', 249.99, 12, 2100),
(2, 'Summit 4 tent', 'tents', 'Alpina', 489.00, 3, 4300),
(3, 'Glow head torch', 'lighting', 'Lumen', 34.50, 40, 90),
(4, 'Basecamp lantern', 'lighting', NULL, 27.00, 15, NULL),
(5, 'Trail 30 backpack', 'packs', 'Kestrel', 89.95, 22, 1150),
(6, 'Day 18 backpack', 'packs', 'Kestrel', 54.00, 0, 640),
(7, 'Merino socks', 'clothing', 'Woolly', 16.00, 75, 80);
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
city VARCHAR(30),
referred_by INTEGER REFERENCES customers (customer_id)
);
INSERT INTO customers VALUES
(1, 'Asha Rao', 'Pune', NULL),
(2, 'Ben Okafor', 'Leeds', 1),
(3, 'Chen Wei', 'Pune', 1),
(4, 'Dana Cruz', 'York', 2),
(5, 'Eli Novak', 'Leeds', NULL),
(6, 'Farah Haddad', NULL, 3);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers (customer_id), -- NULL = guest checkout
placed_on DATE NOT NULL,
status VARCHAR(10) NOT NULL
);
INSERT INTO orders VALUES
(101, 1, DATE '2026-03-02', 'shipped'),
(102, 2, DATE '2026-03-05', 'shipped'),
(103, 1, DATE '2026-03-09', 'delivered'),
(104, 3, DATE '2026-03-15', 'pending'),
(105, 4, DATE '2026-03-20', 'cancelled'),
(106, NULL, DATE '2026-03-22', 'shipped');
CREATE TABLE order_items (
order_id INTEGER REFERENCES orders (order_id),
product_id INTEGER REFERENCES products (product_id),
qty INTEGER NOT NULL,
unit_price DECIMAL(8, 2) NOT NULL,
PRIMARY KEY (order_id, product_id)
);
INSERT INTO order_items VALUES
(101, 1, 1, 249.99), (101, 7, 3, 16.00),
(102, 3, 2, 34.50),
(103, 5, 1, 89.95), (103, 3, 1, 34.50), (103, 7, 2, 15.00),
(104, 2, 1, 489.00),
(105, 6, 1, 54.00),
(106, 7, 1, 16.00);
-- A materialized view stores its result; it must be refreshed to see changes
CREATE MATERIALIZED VIEW category_sales AS
SELECT p.category, SUM(oi.qty * oi.unit_price) AS revenue, COUNT(*) AS lines
FROM order_items oi
JOIN products p ON p.product_id = oi.product_id
GROUP BY p.category;
CREATE UNIQUE INDEX category_sales_uq ON category_sales (category);
SELECT category, revenue FROM category_sales ORDER BY category;
-- A new sale: the materialized view is now out of date
INSERT INTO order_items VALUES (106, 3, 2, 34.50);
SELECT category, revenue FROM category_sales WHERE category = 'lighting';
-- CONCURRENTLY rebuilds it without blocking readers (needs a unique index)
REFRESH MATERIALIZED VIEW CONCURRENTLY category_sales;
SELECT category, revenue FROM category_sales WHERE category = 'lighting';
category | revenue
----------+---------
clothing | 94.00
lighting | 103.50
packs | 143.95
tents | 738.99
(4 rows)
category | revenue
----------+---------
lighting | 103.50
(1 row)
category | revenue
----------+---------
lighting | 172.50
(1 row)
CREATE MATERIALIZED VIEW ... AS SELECT ...runs the query once and stores the rows. Reading it is as fast as reading a small table, and it can be indexed like one.- The stored result doesn't change when the base tables do. After a new lighting sale, the materialized view still shows the old revenue, 103.50.
REFRESH MATERIALIZED VIEWreruns the query and replaces the stored rows. Lighting revenue becomes 172.50.- A plain refresh locks the materialized view against reads while it runs.
CONCURRENTLYbuilds the new result alongside the old one and applies the differences, so readers are never blocked. It requires a unique index on the materialized view, which is why the example creates one oncategory.
Refreshes are usually scheduled, for example every hour with pg_cron or an external scheduler, or run after a batch load. The result is as stale as the time since the last refresh, so materialized views suit dashboards, reports and expensive summaries where slightly old data is acceptable, not account balances.
A PostgreSQL refresh always recomputes the whole query. Other databases can do better: Oracle's materialized views can refresh incrementally (fast refresh) using change logs, and can be used automatically by queries against the base tables (query rewrite). SQL Server's indexed views are kept up to date on every change to the base tables, at the cost of slower writes. MySQL and SQLite have no materialized views: a summary table maintained by a scheduled job or by triggers (article 65) does the same job.
Views, CTEs and temporary tables
All three give a name to a query result, with different lifetimes:
| Lives | Stores data | Use for | |
|---|---|---|---|
CTE (WITH, article 24) | one statement | usually not | breaking one query into steps |
| view | until dropped | no | a query reused by many statements and users |
| materialized view | until dropped | yes, refreshed on demand | an expensive result read often |
| temporary table | the session or transaction | yes | intermediate results within one job |
Synonyms
Oracle and SQL Server have synonyms: alternative names for objects, often in another schema or database, such as CREATE SYNONYM orders FOR sales.orders or Oracle's CREATE PUBLIC SYNONYM, visible to every user. Applications can then refer to orders without a schema prefix, and the synonym can be repointed without changing code. PostgreSQL and MySQL have no synonyms. In PostgreSQL, the schema search_path (article 58) or a simple view over the table does the same job.
What's current
- PostgreSQL 15 added
security_invokerviews, which check the permissions of the user querying the view rather than of its owner, so row-level security policies on the base tables apply (article 58). - PostgreSQL 17 made
REFRESH MATERIALIZED VIEWand other maintenance commands, such asANALYZEandCREATE INDEX, run with a restrictedsearch_path, which can break materialized views whose queries call functions with unqualified names. - Incremental refresh of materialized views is still not built into PostgreSQL. The
pg_ivmextension provides it.
Common questions
Does an ORDER BY inside a view guarantee the order of results?
No. Put ORDER BY in the query that reads the view. An ORDER BY in the view definition isn't guaranteed to survive filters and joins, and SQL Server rejects it without TOP.
Does a view store data? No. It stores a query, which runs when the view is used. A materialized view stores data.
Are views slow? No slower than the equivalent query: the view's query is merged into yours and planned as a whole. A view that does more work than you need can be slower than a targeted query.
Can I insert into a view?
Yes, if it's based on one table without aggregation or DISTINCT. Add WITH CHECK OPTION so rows can't escape the view. For other views, use an INSTEAD OF trigger.
Why can't I change my view with CREATE OR REPLACE? In PostgreSQL, the replacement can only add columns at the end, not remove, rename, reorder or retype existing ones. Drop and recreate the view.
How fresh is a materialized view?
As fresh as its last refresh. Schedule refreshes, and use CONCURRENTLY to avoid blocking readers.
Summary
- A view is a named, stored query. It's used like a table and always shows current data.
- Views give reuse, simpler queries, stable interfaces and column- or row-level security.
- Simple single-table views are updatable.
WITH CHECK OPTIONrejects rows the view couldn't see. - The database tracks dependencies: a view blocks dropping the columns it uses, and
CREATE OR REPLACE VIEWcan only add columns. - A materialized view stores its result for fast reads, and is stale until
REFRESH MATERIALIZED VIEW, whichCONCURRENTLYruns without blocking readers. - Use CTEs within a statement, views across statements, and materialized views for expensive results that can be slightly old.
Practice questions
Create a view big_spenders listing the name and total spend of customers who've spent more than 100, based on customer_summary.
Answer
CREATE VIEW big_spenders AS
SELECT name, spent
FROM customer_summary
WHERE spent > 100;
Views can be built on other views. Keep such stacks shallow.
A view pune_customers is defined as SELECT * FROM customers WHERE city = 'Pune'. What happens when someone runs UPDATE pune_customers SET city = 'Leeds' WHERE customer_id = 1, with and without WITH CHECK OPTION?
Answer
Without it, the update succeeds and customer 1 disappears from the view, since they're no longer in Pune. With WITH CHECK OPTION, the update is rejected because the changed row would fall outside the view.
A dashboard query aggregates 50 million rows and takes 20 seconds, and the dashboard refreshes every minute. Figures up to an hour old are acceptable. What would you suggest?
Answer
A materialized view of the aggregate, with a unique index, refreshed every hour with REFRESH MATERIALIZED VIEW CONCURRENTLY. The dashboard reads the stored result instantly, and the expensive query runs once an hour instead of once a minute.
Why is SELECT * risky inside a view definition?
Answer
In PostgreSQL it's expanded to the table's columns when the view is created, so columns added later don't appear, which surprises people. In databases that re-expand it, the view's columns change when the table does, which can break the applications using it. Listing columns explicitly avoids both.
Previous: SQL Indexes: How They Work and When They Help
Next: Database Metadata: information_schema and the System Catalogs

More in SQL Course
Quiz: SQL Dialect Differences (PostgreSQL, MySQL, SQL Server, Oracle, SQLite)
Twenty-four questions on how the major SQL databases differ: limiting rows, concatenation, empty strings, identifier case, upserts, identity columns, transactional DDL, error handling, isolation defaults, booleans, set operations, RETURNING, dates and typing.
Quiz: SQL Delicate Details
Twenty-five questions on SQL's subtle corners: NULLs in aggregates, IN and CHECK, sort order of NULLs, rounding, CHAR padding, window frame defaults, identity gaps, LIKE escapes, empty groups, set operations and multi-column updates.
Quiz: SQL Interview Questions
Thirty SQL questions of the kind asked in developer and analyst interviews: WHERE vs HAVING, DELETE vs TRUNCATE, keys, joins, duplicates, Nth-highest values, window functions, ACID, isolation, locking, indexes, views, procedures and performance.
Quiz: SQL Course Final Exam (All 15 Parts)
The final exam for the SQL course: thirty questions across all fifteen parts, from query processing, NULLs, joins and aggregation through windows, data changes, types, design, indexes, security, transactions, procedural SQL and tuning.
Discussion
Sign in to ask a question or share what you learned.