Chapter 21. Views

Introduction

SQL supports two types of tables: real tables, generally known as base tables, and derived tables, also called views. Base tables are created with CREATE TABLE statements and are the only ones in which data can be stored. Examples are the PLAYERS and TEAMS tables from the tennis club database.

A derived table, or view, stores no rows itself. Instead, it exists, and can be seen, as a prescription or formula for combining certain data from base tables to make a “virtual” table. The word virtual is used because the contents of a view exist only when it is used in a statement. At that moment, SQL executes the prescription that makes up the view formula and presents the user with what seems to be a real table.

This chapter ...

Get Introduction to SQL: Mastering the Relational Database Language, Fourth Edition/20th Anniversary Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.