Skip to main content

create mysql view,update,drop etc view operation.

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


Comments

Popular posts from this blog

Profile Share Fixing the Thumbnail Image, Title and Description for Shared Links

Profile Share Fixing the Thumbnail Image, Title and Description for Shared Links user want to share any information then use following code  and read step by step Profile Share Fixing the Thumbnail Image, Title and Description for Shared Links if you want share profile on following social link : 1-Facebook 2-twitter.com 3-LinkedIn 4-google +, Code link : https://drive.google.com/open?id=1IzTZZh_0euDqFSHL_vPRiQePlNTw3h-q Demo link : http://freeteachnology.hol.es/socialshare/ To modify a page's thumbnail image, description, and additional metadata for these services, you can provide meta tags in the HTML code of the page.Implementing Open Graph Meta Tags You can implement meta tags in a number of ways. In content management systems might  be allow you to modify a page's meta tags , then use following code in meta section of your project code, <link href="bootstrap.min.css" rel="stylesheet"> <link href="bootstrap-tour.m...

using PDO database connection add,update,delete,edit operation

PDO advantage : 1-Object Oriented 2-Bind parameters in statements (security) 3-Allows for prepared statements and rollback functionality (consistency) 4-Throws catcheable exceptions for better error handling (quality) 5-Exception mode; no need to check error state after each API call. It's best to tell PDO how you'd like the data to be fetched. You have the following options: 1-PDO::FETCH_ASSOC: returns an array indexed by column name. 2-PDO::FETCH_BOTH: (default):returns an array indexed by both column name and number. 3-PDO::FETCH_BOUND:Assigns the values of your columns to the variables set with the ->bindColumn() method. 4-PDO::FETCH_CLASS: Assigns the values of your columns to properties of the named class. It will create the properties if matching properties do not exist. 5-PDO::FETCH_INTO:Updates an existing instance of the named class. 6-PDO::FETCH_LAZY: Combines. 7-PDO::FETCH_BOTH/PDO:FETCH_OBJ, creating the object variable names as t...

Ajax Asynchronous and synchronus using jquery

What is jQuery 1-jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto - 2-Write less, do more. 3-jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. Following feature of jQuery : 1-DOM manipulation − The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine called Sizzle. 2-Event Handling : The jQuery offers an elegant way to capture a wide variety of events,such as click,over event, 3-Ajax Support : jQuery support ajax technology, 4- Lightweight : he jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ) . 5-Animations − The jQuery comes with plenty of built-in animation effects. 6-Cross Br...