SQL Views |
Syntax:
The syntax for the CREATE VIEW statement is,
Examples:
Table1 : Bills
NAME | AMOUNT | ACCOUNT_ID |
---|---|---|
Software Company | $75 | 1 |
Phone Company | $25 | 2 |
Power Company | $250 | 2 |
Record Club | $35 | 3 |
Exploring a Simple View
Input1 :
CREATE VIEW DEPTS AS
SELECT *
FROM BILLS;
Input2 :
SELECT *
FROM DEBTS;
Results
Output1:
In this example, we have created a view called DEBTS that is based on the BILLS table. Notice that we did not specify a column list directly after the CREATE VIEW statement. Since we did not specify a column list, the column names in the view inherit the same names as the columns selected from the base table.
Comments