In this case, the record actually inserted into the underlying base table. It is possible in MySQL to perform INSERT Operation on Simple View. Here, we are querying the view which internally fetches the data from the underlying base table i.e. When you execute the above SQL Statement, you will get the following output. So, the following SQL query will retrieve all the data from the Employee table as the view created on the Employee table. To retrieve the data from a view, we need to use the SELECT statement, in the same way, we used to select the data from a table. As we already discussed we can perform all the DML Operations on Simple view. Employee table, so it is called a Simple view and updatable view. Once you execute the above statement, the view vwEmployee is created inside the Views folder as shown in the below image.Īs the above view is created based on a single table i.e. Now we will create a view that will retrieve all the column data from the Employee table.ĬREATE VIEW vwEmployee AS SELECT * FROM Employee Let us understand Simple Views in MySQL with Examples. In the Simple View, we can perform all the DML operations, so it is also called an updatable view. The view that is created based on the columns of a single table is known as a simple view in MySQL. What is a simple view or an Updatable view in MySQL? There are two types of views in MySQL, they are as follows. How many types of views are there in MySQL? As you can see in the below image, the MySQL Views will be created by using a select statement. The Syntax to Create a View in MySQL is shown below. INSERT INTO Employee VALUES(6, 'Hina', 2, 45000, 'HR') INSERT INTO Employee VALUES(5, 'Sambit', 3, 35000, 'INFRA') INSERT INTO Employee VALUES(4, 'Preety', 2, 25000, 'HR') INSERT INTO Employee VALUES(3, 'Anurag', 1, 40000, 'IT') INSERT INTO Employee VALUES(2, 'Priyanka', 2, 30000, 'HR') INSERT INTO Employee VALUES(1, 'Pranaya', 1, 20000, 'IT') Populate the Employee Table with test data Populate the Gender Table with test data Please use the below SQL Script to create and populate the database EmployeeDB, and Gender and Employee table with the required sample data. We are going to use the following Gender and Employee table to understand the Views in MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |