View is a data object which does not contain any data. Contents of the view are the resultant of a base table. They are operated just like base table but they don’t contain any data of their own. The difference between a view and a table is that views are definitions built on top of other tables (or views). If data is changed in the underlying table, the same change is reflected in the view. A view can be built on top of a single or multiple tables.
A database view is known as a “virtual table” that allows you to query the data in it. Understanding the database views and using them correctly are very important.
we will discuss the database views, how they are implemented in MySQL,A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
Introduction to Database View
Why views ?
1-Views can be effective copies of base tables.
2-Views can be used in INSERT/UPDATE/DELETE.
3-Views can be views of views.
important note view are use only MySQL Views need Version 5.0 or higher
check your mysql version using folloing command :
cmd:
mysql>SELECT VERSION();
Create View
Following statements create a view. By default, a view is associated with the default database (currently used the database). To associate the view with a given database, specify the name as database_name. view_name when you create it. Here is the complete syntax :
Syntax :
CREATE
[OR REPLACE]
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = { user | CURRENT_USER }]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
Dropping views
The DROP command can be used to delete a view from the database that is no longer required. The basic syntax to drop a view is as follows.
Syntax:
DROP VIEW ` general_v_movie_rentals `;
SQL Updating a View
You can update a view by using the following syntax:
Syntax:
SQL CREATE OR REPLACE VIEW Syntax
CREATE OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
i hope that you can enjoy mysql view operation and like my blog
A database view is known as a “virtual table” that allows you to query the data in it. Understanding the database views and using them correctly are very important.
we will discuss the database views, how they are implemented in MySQL,A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
Introduction to Database View
Why views ?
1-Views can be effective copies of base tables.
2-Views can be used in INSERT/UPDATE/DELETE.
3-Views can be views of views.
important note view are use only MySQL Views need Version 5.0 or higher
check your mysql version using folloing command :
cmd:
mysql>SELECT VERSION();
Create View
Following statements create a view. By default, a view is associated with the default database (currently used the database). To associate the view with a given database, specify the name as database_name. view_name when you create it. Here is the complete syntax :
Syntax :
CREATE
[OR REPLACE]
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = { user | CURRENT_USER }]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
Dropping views
The DROP command can be used to delete a view from the database that is no longer required. The basic syntax to drop a view is as follows.
Syntax:
DROP VIEW ` general_v_movie_rentals `;
SQL Updating a View
You can update a view by using the following syntax:
Syntax:
SQL CREATE OR REPLACE VIEW Syntax
CREATE OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
i hope that you can enjoy mysql view operation and like my blog
Comments