A View is nothing more than a SQLite statement stored in the database by the associated name. A View is actually a combination of tables that exist in the form of a predefined SQLite query.
A View can contain all rows of a table or select rows from one or more tables. Views (View) can be created from one or more tables, depending on the SQLite query in which you want to create the view.
A View is a virtual table that allows the user to implement the following:
Users or user groups find structural data in a more natural or intuitive way.
Restrict data access, and users can only see limited data, not complete tables.
Summarize the data from various tables to generate reports.
The SQLite view is read-only and may not be executed on the view The view of SQLite is to use the CREATE VIEW Statement. SQLite views can be created from a single table, multiple tables, or other views. The basic syntax of CREATE VIEW is as follows: You can find it in the Hypothetical Now, here is an example from Now, you can query This will produce the following results: 要删除视图,只需使用带有 The following command will delete the
DELETE
,
INSERT
or
UPDATE
Statement. But you can create a trigger on the view when you try
DELETE
,
INSERT
or
UPDATE
When the view is triggered, the actions to be done are defined in the contents of the trigger. 1.39.1. Create a view ¶
CREATE [TEMP | TEMPORARY] VIEW view_name AS
SELECT column1, column2.....
FROM table_name
WHERE [condition];
SELECT
Statement contains multiple tables, which is the same as in the normal
SQL
SELECT
The manner in the query is very similar. If you use the optional
TEMP
Or
TEMPORARY
Keyword, the view is created in the tempdb. 1.39.2. Example ¶
COMPANY
The table has the following records:ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
3 Teddy 23 Norway 20000.0
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0
6 Kim 22 South-Hall 45000.0
7 James 24 Houston 10000.0
COMPANY
Table creates an instance of the view. The view is only from
COMPANY
Select several columns from the table:sqlite> CREATE VIEW COMPANY_VIEW AS
SELECT ID, NAME, AGE
FROM COMPANY;
COMPANY_VIEW
Similar to the way you query the actual table Here is an example:sqlite> SELECT * FROM COMPANY_VIEW;
ID NAME AGE
---------- ---------- ----------
1 Paul 32
2 Allen 25
3 Teddy 23
4 Mark 25
5 David 27
6 Kim 22
7 James 24
1.39.3. Delete View ¶
view_name
的
DROP
VIEW
语句。
DROP
VIEW
的基本语法如下:sqlite> DROP VIEW view_name;
COMPANY_VIEW
View:sqlite> DROP VIEW COMPANY_VIEW;