{"id":4002,"date":"2026-11-23T22:06:44","date_gmt":"2026-11-23T16:36:44","guid":{"rendered":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql"},"modified":"2026-11-23T22:43:01","modified_gmt":"2026-11-23T17:13:01","slug":"views-in-sql","status":"publish","type":"post","link":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql","title":{"rendered":"Views in SQL: How to Create, Use and Update a View"},"content":{"rendered":"<p>A view in SQL is a saved SELECT query with a name. You create it once with CREATE VIEW, and from then on you can query it exactly like a table, but it stores no data of its own: every time you read from a view, the database runs the query behind it against the current rows in the underlying tables. That is why a view is often called a virtual table.<\/p>\n<p>Analysts use views for three jobs: to save a join or a filter that every report needs, to give a dashboard one stable thing to read, and to hide columns (phone numbers, salaries) from people who should not see them. This lesson covers all three with worked examples, then the parts that trip people up: updating through a view, materialized views, and where the main databases differ.<\/p>\n<h2>View syntax<\/h2>\n<p>These are the statements you will use. The examples refer to the skincare brand data introduced in the next section.<\/p>\n<table>\n<thead>\n<tr>\n<th>Statement<\/th>\n<th>What it does<\/th>\n<th>Syntax<\/th>\n<th>Example<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>CREATE VIEW<\/td>\n<td>Saves a query under a name<\/td>\n<td>CREATE VIEW name AS SELECT &#8230;<\/td>\n<td>CREATE VIEW delivered_orders AS SELECT order_id, amount FROM orders WHERE status = &#8216;Delivered&#8217;<\/td>\n<\/tr>\n<tr>\n<td>Query a view<\/td>\n<td>Reads it like a table<\/td>\n<td>SELECT &#8230; FROM view_name<\/td>\n<td>SELECT * FROM delivered_orders WHERE amount &gt; 1000<\/td>\n<\/tr>\n<tr>\n<td>Replace a view<\/td>\n<td>Changes the saved query, keeps the name<\/td>\n<td>CREATE OR REPLACE VIEW name AS SELECT &#8230;<\/td>\n<td>CREATE OR REPLACE VIEW delivered_orders AS SELECT order_id, order_date, amount FROM orders WHERE status = &#8216;Delivered&#8217;<\/td>\n<\/tr>\n<tr>\n<td>DROP VIEW<\/td>\n<td>Deletes the view, not the data<\/td>\n<td>DROP VIEW name<\/td>\n<td>DROP VIEW delivered_orders<\/td>\n<\/tr>\n<tr>\n<td>Column names<\/td>\n<td>Renames the view&#8217;s columns<\/td>\n<td>CREATE VIEW name (col1, col2) AS SELECT &#8230;<\/td>\n<td>CREATE VIEW city_sales (city, revenue) AS SELECT city, SUM(amount) FROM &#8230;<\/td>\n<\/tr>\n<tr>\n<td>WITH CHECK OPTION<\/td>\n<td>Blocks writes through the view that the view could not see<\/td>\n<td>CREATE VIEW name AS SELECT &#8230; WHERE &#8230; WITH CHECK OPTION<\/td>\n<td>CREATE VIEW big_orders AS SELECT * FROM orders WHERE amount &gt; 1000 WITH CHECK OPTION<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>CREATE OR REPLACE VIEW works in MySQL and PostgreSQL. SQL Server writes it CREATE OR ALTER VIEW, and SQLite has neither, so there you DROP VIEW and create it again.<\/p>\n<h2>The data used throughout<\/h2>\n<p>The examples use a Bengaluru D2C skincare brand that sells across India. There are two tables. The customers table holds customer_id, name, city and a phone number; the orders table holds every order with its status. Amounts are in rupees.<\/p>\n<table>\n<thead>\n<tr>\n<th>customer_id<\/th>\n<th>name<\/th>\n<th>city<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>C1<\/td>\n<td>Ananya Rao<\/td>\n<td>Bengaluru<\/td>\n<\/tr>\n<tr>\n<td>C2<\/td>\n<td>Rohit Mehta<\/td>\n<td>Mumbai<\/td>\n<\/tr>\n<tr>\n<td>C3<\/td>\n<td>Sneha Iyer<\/td>\n<td>Chennai<\/td>\n<\/tr>\n<tr>\n<td>C4<\/td>\n<td>Karan Gill<\/td>\n<td>Bengaluru<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>order_id<\/th>\n<th>customer_id<\/th>\n<th>order_date<\/th>\n<th>amount<\/th>\n<th>status<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>9101<\/td>\n<td>C1<\/td>\n<td>2026-10-03<\/td>\n<td>1299<\/td>\n<td>Delivered<\/td>\n<\/tr>\n<tr>\n<td>9102<\/td>\n<td>C2<\/td>\n<td>2026-10-05<\/td>\n<td>849<\/td>\n<td>Delivered<\/td>\n<\/tr>\n<tr>\n<td>9103<\/td>\n<td>C3<\/td>\n<td>2026-10-11<\/td>\n<td>1599<\/td>\n<td>Cancelled<\/td>\n<\/tr>\n<tr>\n<td>9104<\/td>\n<td>C1<\/td>\n<td>2026-10-18<\/td>\n<td>699<\/td>\n<td>Delivered<\/td>\n<\/tr>\n<tr>\n<td>9105<\/td>\n<td>C4<\/td>\n<td>2026-11-02<\/td>\n<td>2199<\/td>\n<td>Delivered<\/td>\n<\/tr>\n<tr>\n<td>9106<\/td>\n<td>C2<\/td>\n<td>2026-11-04<\/td>\n<td>1149<\/td>\n<td>Returned<\/td>\n<\/tr>\n<tr>\n<td>9107<\/td>\n<td>C3<\/td>\n<td>2026-11-07<\/td>\n<td>999<\/td>\n<td>Delivered<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Example 1: save the join every report repeats<\/h2>\n<p>Every revenue report at this brand needs the same two things: only delivered orders count, and city comes from the customers table. Without a view, every analyst writes that join and that filter into every query, and sooner or later someone forgets the status filter and counts cancelled orders as revenue.<\/p>\n<p>So save it once:<\/p>\n<table>\n<thead>\n<tr>\n<th>Step<\/th>\n<th>SQL<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Create the view<\/td>\n<td>CREATE VIEW delivered_orders AS<\/td>\n<\/tr>\n<tr>\n<td>Its query<\/td>\n<td>SELECT o.order_id, o.order_date, c.city, o.amount<\/td>\n<\/tr>\n<tr>\n<td>The join<\/td>\n<td>FROM orders o JOIN customers c ON c.customer_id = o.customer_id<\/td>\n<\/tr>\n<tr>\n<td>The rule everyone must apply<\/td>\n<td>WHERE o.status = &#8216;Delivered&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Now SELECT * FROM delivered_orders returns five rows. The cancelled and returned orders are gone, and city has been attached:<\/p>\n<table>\n<thead>\n<tr>\n<th>order_id<\/th>\n<th>order_date<\/th>\n<th>city<\/th>\n<th>amount<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>9101<\/td>\n<td>2026-10-03<\/td>\n<td>Bengaluru<\/td>\n<td>1299<\/td>\n<\/tr>\n<tr>\n<td>9102<\/td>\n<td>2026-10-05<\/td>\n<td>Mumbai<\/td>\n<td>849<\/td>\n<\/tr>\n<tr>\n<td>9104<\/td>\n<td>2026-10-18<\/td>\n<td>Bengaluru<\/td>\n<td>699<\/td>\n<\/tr>\n<tr>\n<td>9105<\/td>\n<td>2026-11-02<\/td>\n<td>Bengaluru<\/td>\n<td>2199<\/td>\n<\/tr>\n<tr>\n<td>9107<\/td>\n<td>2026-11-07<\/td>\n<td>Chennai<\/td>\n<td>999<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Anyone can now write a short query on top of it. SELECT city, COUNT(*) AS orders, SUM(amount) AS revenue FROM delivered_orders GROUP BY city ORDER BY revenue DESC gives:<\/p>\n<table>\n<thead>\n<tr>\n<th>city<\/th>\n<th>orders<\/th>\n<th>revenue<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Bengaluru<\/td>\n<td>3<\/td>\n<td>4197<\/td>\n<\/tr>\n<tr>\n<td>Chennai<\/td>\n<td>1<\/td>\n<td>999<\/td>\n<\/tr>\n<tr>\n<td>Mumbai<\/td>\n<td>1<\/td>\n<td>849<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The person writing that query does not need to know the join exists, or that &#8220;revenue&#8221; at this company excludes returns. The view carries the business rule, and when the rule changes (say, finance decides returned orders should count until the refund clears), you change one view instead of forty queries.<\/p>\n<h2>Example 2: a view built on a view, for a dashboard<\/h2>\n<p>A Power BI or Tableau dashboard works best when it reads one tidy table. Here the dashboard needs revenue by month and city, so the second view reads from the first:<\/p>\n<table>\n<thead>\n<tr>\n<th>Step<\/th>\n<th>SQL (MySQL)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Create the view<\/td>\n<td>CREATE VIEW monthly_city_revenue AS<\/td>\n<\/tr>\n<tr>\n<td>Month and totals<\/td>\n<td>SELECT DATE_FORMAT(order_date, &#8216;%Y-%m&#8217;) AS month, city, COUNT(*) AS orders, SUM(amount) AS revenue<\/td>\n<\/tr>\n<tr>\n<td>Source<\/td>\n<td>FROM delivered_orders<\/td>\n<\/tr>\n<tr>\n<td>Grouping<\/td>\n<td>GROUP BY DATE_FORMAT(order_date, &#8216;%Y-%m&#8217;), city<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>SELECT * FROM monthly_city_revenue ORDER BY month, city returns:<\/p>\n<table>\n<thead>\n<tr>\n<th>month<\/th>\n<th>city<\/th>\n<th>orders<\/th>\n<th>revenue<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>2026-10<\/td>\n<td>Bengaluru<\/td>\n<td>2<\/td>\n<td>1998<\/td>\n<\/tr>\n<tr>\n<td>2026-10<\/td>\n<td>Mumbai<\/td>\n<td>1<\/td>\n<td>849<\/td>\n<\/tr>\n<tr>\n<td>2026-11<\/td>\n<td>Bengaluru<\/td>\n<td>1<\/td>\n<td>2199<\/td>\n<\/tr>\n<tr>\n<td>2026-11<\/td>\n<td>Chennai<\/td>\n<td>1<\/td>\n<td>999<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The month expression is the only part that changes between databases: PostgreSQL uses TO_CHAR(order_date, &#8216;YYYY-MM&#8217;), SQL Server uses FORMAT(order_date, &#8216;yyyy-MM&#8217;), and SQLite uses strftime(&#8216;%Y-%m&#8217;, order_date). Our lesson on date functions in SQL has the full list.<\/p>\n<p>One level of view on view is fine. Five levels is a known source of pain, covered under mistakes below.<\/p>\n<h2>Example 3: a view always shows current data<\/h2>\n<p>Because a view stores the query and not the result, new rows appear in it immediately. Insert a delivered order for C4 on 9 November for 1,799 rupees:<\/p>\n<table>\n<thead>\n<tr>\n<th>Step<\/th>\n<th>SQL<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>New order<\/td>\n<td>INSERT INTO orders VALUES (9108, &#8216;C4&#8217;, &#8216;2026-11-09&#8217;, 1799, &#8216;Delivered&#8217;)<\/td>\n<\/tr>\n<tr>\n<td>Read the view again<\/td>\n<td>SELECT * FROM monthly_city_revenue WHERE month = &#8216;2026-11&#8217; ORDER BY city<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>month<\/th>\n<th>city<\/th>\n<th>orders<\/th>\n<th>revenue<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>2026-11<\/td>\n<td>Bengaluru<\/td>\n<td>2<\/td>\n<td>3998<\/td>\n<\/tr>\n<tr>\n<td>2026-11<\/td>\n<td>Chennai<\/td>\n<td>1<\/td>\n<td>999<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Nobody refreshed anything. The flip side is cost: if the query behind a view takes 40 seconds on a large orders table, every read of the view takes 40 seconds too. A view saves typing, not computing.<\/p>\n<h2>Using a view to hide columns<\/h2>\n<p>The customers table holds phone numbers. The marketing team needs city counts but should never see personal data. Create a view without the sensitive column and give them access to the view only:<\/p>\n<table>\n<thead>\n<tr>\n<th>Step<\/th>\n<th>SQL<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A view without phone numbers<\/td>\n<td>CREATE VIEW customer_cities AS SELECT customer_id, city FROM customers<\/td>\n<\/tr>\n<tr>\n<td>Grant read access to the view<\/td>\n<td>GRANT SELECT ON customer_cities TO marketing_team<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The team can query customer_cities freely and has no permission on customers itself. This column-level and row-level restriction is one of the oldest uses of views, and it matters more in India since the Digital Personal Data Protection Act, 2023, made companies more careful about who can read personal data. SQLite has no users or GRANT, so this part applies to MySQL, PostgreSQL and SQL Server.<\/p>\n<h2>Can you update data through a view?<\/h2>\n<p>Sometimes. A view is updatable when each row in it maps back to exactly one row in one base table. In practice that means the view&#8217;s query has:<\/p>\n<ul>\n<li>one base table, or (in MySQL and SQL Server) a join where only one table&#8217;s columns are changed<\/li>\n<li>no GROUP BY, DISTINCT, aggregate functions or UNION<\/li>\n<li>the columns being changed taken directly from the table, not calculated<\/li>\n<\/ul>\n<p>So UPDATE delivered_orders SET amount = 1349 WHERE order_id = 9101 works in MySQL and SQL Server, and changes the row in orders. PostgreSQL is stricter: a view is automatically updatable only when its FROM clause names a single table, so the joined delivered_orders view needs a trigger there, while a single-table view such as big_orders updates directly. An UPDATE on monthly_city_revenue fails, because a monthly total has no single row to go back to. SQLite views are read-only; writing through one needs an INSTEAD OF trigger.<\/p>\n<p>WITH CHECK OPTION closes a quiet loophole. Without it, you can insert a row through a view that the view itself would never show, such as a Cancelled order inserted through delivered_orders. With it, the database rejects any insert or update through the view that would fall outside its WHERE clause.<\/p>\n<p>Most analysts never write through views, and that is a sensible default. Treat views as read-only and change data in the base tables.<\/p>\n<h2>Materialized views: when the query is too slow<\/h2>\n<p>A materialized view stores the result, like a table, and refreshes it on command or on a schedule. Reads are fast because nothing is recomputed. The cost is that the data is only as fresh as the last refresh.<\/p>\n<table>\n<thead>\n<tr>\n<th>Point<\/th>\n<th>MySQL<\/th>\n<th>PostgreSQL<\/th>\n<th>SQL Server<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Normal view<\/td>\n<td>CREATE VIEW<\/td>\n<td>CREATE VIEW<\/td>\n<td>CREATE VIEW<\/td>\n<\/tr>\n<tr>\n<td>Replace a view<\/td>\n<td>CREATE OR REPLACE VIEW<\/td>\n<td>CREATE OR REPLACE VIEW<\/td>\n<td>CREATE OR ALTER VIEW<\/td>\n<\/tr>\n<tr>\n<td>Materialized view<\/td>\n<td>Not supported; use a summary table refreshed by a scheduled event<\/td>\n<td>CREATE MATERIALIZED VIEW name AS SELECT &#8230;<\/td>\n<td>Indexed view: CREATE VIEW &#8230; WITH SCHEMABINDING, then a unique clustered index<\/td>\n<\/tr>\n<tr>\n<td>Refresh<\/td>\n<td>Your own job<\/td>\n<td>REFRESH MATERIALIZED VIEW name<\/td>\n<td>Automatic on every base-table change<\/td>\n<\/tr>\n<tr>\n<td>ORDER BY inside a view<\/td>\n<td>Allowed, but do not rely on it<\/td>\n<td>Allowed, but do not rely on it<\/td>\n<td>Not allowed without TOP<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Cloud warehouses such as BigQuery and Snowflake also offer materialized views, refreshed automatically. For a daily dashboard on millions of rows, a materialized view refreshed overnight is the usual answer.<\/p>\n<h2>View vs table vs CTE<\/h2>\n<p>Analysts mix these up because all three can be selected from. The difference is what they store and how long they last.<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Table<\/th>\n<th>View<\/th>\n<th>Materialized view<\/th>\n<th>CTE<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Stores rows<\/td>\n<td>Yes<\/td>\n<td>No, only the query<\/td>\n<td>Yes, a snapshot<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Lasts<\/td>\n<td>Until dropped<\/td>\n<td>Until dropped<\/td>\n<td>Until dropped<\/td>\n<td>One query<\/td>\n<\/tr>\n<tr>\n<td>Data is current<\/td>\n<td>Yes<\/td>\n<td>Yes, always<\/td>\n<td>As of last refresh<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Shared with other users<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Typical use<\/td>\n<td>Raw data<\/td>\n<td>Reusable logic and access control<\/td>\n<td>Fast reads of heavy summaries<\/td>\n<td>Steps inside one long query<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If the logic is for one query you are writing today, use a CTE, which our CTE in SQL lesson covers. If other people or a dashboard will reuse it next month, make it a view.<\/p>\n<h2>Mistakes people make with views<\/h2>\n<p>**Using SELECT * in a view definition.** MySQL, PostgreSQL and SQL Server all expand the star into a fixed column list when the view is created. Add a column to the table later and the view does not show it, and in SQL Server a dropped or reordered column can make the view return the wrong data. List the columns.<\/p>\n<p><strong>Stacking views five deep.<\/strong> A view on a view on a view is hard to debug, and the optimiser may not simplify it well. When a dashboard is slow and the source is a tower of views, flatten it.<\/p>\n<p><strong>Expecting a view to be faster.<\/strong> A normal view runs its full query every time. If speed is the problem, you need a materialized view, an index, or a summary table.<\/p>\n<p><strong>Dropping a table that views depend on.<\/strong> Most databases let you drop the table, and the view then fails on its next read. Before dropping or renaming anything, check which views read from it.<\/p>\n<p><strong>Putting ORDER BY inside the view.<\/strong> Sort in the query that reads the view. Order inside a view is not guaranteed to survive into the outer result.<\/p>\n<p>Views sit naturally on top of joins, so if the join in Example 1 looked unfamiliar, start with our <a href=\"https:\/\/www.skillovilla.com\/blogs\/sql-joins\">SQL joins guide<\/a>. CREATE VIEW is also a DDL statement, alongside the CREATE, ALTER and DROP commands in <a href=\"https:\/\/www.skillovilla.com\/blogs\/ddl-commands-in-sql\">DDL commands in SQL<\/a>, and views come up regularly in our <a href=\"https:\/\/www.skillovilla.com\/blogs\/sql-interview-questions\">SQL interview questions<\/a>.<\/p>\n<h2>Frequently asked questions<\/h2>\n<h3>What is a view in SQL?<\/h3>\n<p>A view is a named, saved SELECT query that you can query like a table. It stores no data itself; each time you read from it, the database runs its query against the underlying tables, so the result is always current. Views are used to reuse complex logic, give reports a stable source, and restrict which columns or rows a user can see.<\/p>\n<h3>What is the difference between a view and a table?<\/h3>\n<p>A table stores rows on disk. A view stores only a query and produces its rows when you read it. Deleting a view removes nothing from the underlying tables, while dropping a table deletes its data. A view can combine several tables, filter them and calculate columns, all of which a plain table cannot do by itself.<\/p>\n<h3>Can we insert or update data through a view?<\/h3>\n<p>Yes, if the view is simple enough that each of its rows maps to one row in one base table: no GROUP BY, DISTINCT, aggregates or UNION. MySQL, PostgreSQL and SQL Server all support this, though PostgreSQL only for views over a single table. Adding WITH CHECK OPTION stops inserts or updates that would create rows the view itself cannot see.<\/p>\n<h3>What is a materialized view?<\/h3>\n<p>A materialized view stores the result of its query physically, so reading it is fast, and it is refreshed on demand or on a schedule. PostgreSQL supports it with CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW. SQL Server offers indexed views for the same purpose, and MySQL has no native version, so teams use a summary table refreshed by a scheduled job.<\/p>\n<h3>Does a view improve query performance?<\/h3>\n<p>A normal view does not, because it runs its full query every time it is read. It can make queries easier to write and maintain, but not faster. For performance, use a materialized view, an indexed view in SQL Server, or a summary table, and make sure the base tables are indexed on the columns the view joins and filters on.<\/p>\n<h3>How do I change or delete a view?<\/h3>\n<p>Use CREATE OR REPLACE VIEW in MySQL and PostgreSQL, or CREATE OR ALTER VIEW in SQL Server, to change the query while keeping the name. ALTER VIEW also works in MySQL and SQL Server. DROP VIEW name deletes the view and leaves the underlying data untouched.<\/p>\n<h2>Build the queries other people&#8217;s reports run on<\/h2>\n<p>Writing a view is easy. Knowing which business rules belong in one, and getting the join underneath it right so a dashboard does not quietly double-count, is the part that takes practice on real data with feedback.<\/p>\n<p>SkilloVilla&#8217;s <a href=\"https:\/\/www.skillovilla.com\/courses\/sql-beginner-to-advanced\">SQL: Beginner to Advanced course<\/a> covers creating databases, conditional functions, aggregation, joins and advanced SQL statements, taught in live classes with mentor support and practice on SQL playgrounds. If you want SQL inside a full analyst programme with Excel, Python, Power BI and placement support, see the <a href=\"https:\/\/www.skillovilla.com\/tracks\/data-analytics-python\">Data Analytics with Python track<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Views in SQL explained: what a view is, CREATE VIEW syntax, updatable and materialized views, and view vs table, with worked examples.<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[200],"tags":[],"class_list":["post-4002","post","type-post","status-publish","format-standard","hentry","category-data-analytics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Views in SQL: How to Create, Use and Update a View<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Views in SQL: How to Create, Use and Update a View\" \/>\n<meta property=\"og:description\" content=\"Views in SQL explained: what a view is, CREATE VIEW syntax, updatable and materialized views, and view vs table, with worked examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\" \/>\n<meta property=\"og:site_name\" content=\"SkilloVilla\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-23T16:36:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-23T17:13:01+00:00\" \/>\n<meta name=\"author\" content=\"SkilloVilla Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SkilloVilla Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\"},\"author\":{\"name\":\"SkilloVilla Team\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/f64a2675b6d238b7e44744a87e5c4943\"},\"headline\":\"Views in SQL: How to Create, Use and Update a View\",\"datePublished\":\"2026-11-23T16:36:44+00:00\",\"dateModified\":\"2026-11-23T17:13:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\"},\"wordCount\":2397,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#organization\"},\"articleSection\":[\"Data analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\",\"url\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\",\"name\":\"Views in SQL: How to Create, Use and Update a View\",\"isPartOf\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#website\"},\"datePublished\":\"2026-11-23T16:36:44+00:00\",\"dateModified\":\"2026-11-23T17:13:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.skillovilla.com\/blogs\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Views in SQL: How to Create, Use and Update a View\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#website\",\"url\":\"https:\/\/www.skillovilla.com\/blogs\/\",\"name\":\"SkilloVilla\",\"description\":\"Data careers, taught live\",\"publisher\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.skillovilla.com\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#organization\",\"name\":\"SkilloVilla\",\"url\":\"https:\/\/www.skillovilla.com\/blogs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.skillovilla.com\/blogs\/wp-content\/uploads\/2021\/07\/logo-thumbnail.png\",\"contentUrl\":\"https:\/\/www.skillovilla.com\/blogs\/wp-content\/uploads\/2021\/07\/logo-thumbnail.png\",\"width\":1200,\"height\":627,\"caption\":\"SkilloVilla\"},\"image\":{\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/f64a2675b6d238b7e44744a87e5c4943\",\"name\":\"SkilloVilla Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5e0b6f9e8405f5d6fc302700051e351ffa38fb1cf2709a0cb4e96b5622c497d0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5e0b6f9e8405f5d6fc302700051e351ffa38fb1cf2709a0cb4e96b5622c497d0?s=96&d=mm&r=g\",\"caption\":\"SkilloVilla Team\"},\"url\":\"https:\/\/www.skillovilla.com\/blogs\/author\/sankalp_agarwal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Views in SQL: How to Create, Use and Update a View","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql","og_locale":"en_US","og_type":"article","og_title":"Views in SQL: How to Create, Use and Update a View","og_description":"Views in SQL explained: what a view is, CREATE VIEW syntax, updatable and materialized views, and view vs table, with worked examples.","og_url":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql","og_site_name":"SkilloVilla","article_published_time":"2026-11-23T16:36:44+00:00","article_modified_time":"2026-11-23T17:13:01+00:00","author":"SkilloVilla Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"SkilloVilla Team","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#article","isPartOf":{"@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql"},"author":{"name":"SkilloVilla Team","@id":"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/f64a2675b6d238b7e44744a87e5c4943"},"headline":"Views in SQL: How to Create, Use and Update a View","datePublished":"2026-11-23T16:36:44+00:00","dateModified":"2026-11-23T17:13:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql"},"wordCount":2397,"commentCount":0,"publisher":{"@id":"https:\/\/www.skillovilla.com\/blogs\/#organization"},"articleSection":["Data analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.skillovilla.com\/blogs\/views-in-sql#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql","url":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql","name":"Views in SQL: How to Create, Use and Update a View","isPartOf":{"@id":"https:\/\/www.skillovilla.com\/blogs\/#website"},"datePublished":"2026-11-23T16:36:44+00:00","dateModified":"2026-11-23T17:13:01+00:00","breadcrumb":{"@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.skillovilla.com\/blogs\/views-in-sql"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.skillovilla.com\/blogs\/views-in-sql#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.skillovilla.com\/blogs"},{"@type":"ListItem","position":2,"name":"Views in SQL: How to Create, Use and Update a View"}]},{"@type":"WebSite","@id":"https:\/\/www.skillovilla.com\/blogs\/#website","url":"https:\/\/www.skillovilla.com\/blogs\/","name":"SkilloVilla","description":"Data careers, taught live","publisher":{"@id":"https:\/\/www.skillovilla.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.skillovilla.com\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.skillovilla.com\/blogs\/#organization","name":"SkilloVilla","url":"https:\/\/www.skillovilla.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/www.skillovilla.com\/blogs\/wp-content\/uploads\/2021\/07\/logo-thumbnail.png","contentUrl":"https:\/\/www.skillovilla.com\/blogs\/wp-content\/uploads\/2021\/07\/logo-thumbnail.png","width":1200,"height":627,"caption":"SkilloVilla"},"image":{"@id":"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/f64a2675b6d238b7e44744a87e5c4943","name":"SkilloVilla Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skillovilla.com\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5e0b6f9e8405f5d6fc302700051e351ffa38fb1cf2709a0cb4e96b5622c497d0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5e0b6f9e8405f5d6fc302700051e351ffa38fb1cf2709a0cb4e96b5622c497d0?s=96&d=mm&r=g","caption":"SkilloVilla Team"},"url":"https:\/\/www.skillovilla.com\/blogs\/author\/sankalp_agarwal"}]}},"_links":{"self":[{"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/posts\/4002","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/comments?post=4002"}],"version-history":[{"count":2,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/posts\/4002\/revisions"}],"predecessor-version":[{"id":4057,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/posts\/4002\/revisions\/4057"}],"wp:attachment":[{"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/media?parent=4002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/categories?post=4002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skillovilla.com\/blogs\/wp-json\/wp\/v2\/tags?post=4002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}