
How to create view in MySQL database
In MySQL, you can use simple CREATE VIEW
statement to create a view in database. A view is a saved query that acts like a virtual table. It doesn't store the actual data but provides a way to present the results of a query as if it were a table, making it easier to retrieve specific information without altering the original data.
-
Create view Statement in MySQL
CREATE VIEW employeeNames as select EmpID, EmpName from employee;
Output
mysql> CREATE VIEW employeeNames as select EmpID, EmpName from employee; Query OK, 0 rows affected (0.02 sec)
You can use above statement to create a view in MySQL table.
-
Employee table structure
Create table statement to create Employee table.
You can create the Employee table with columns EmpID, EmpName, Mobile, PresentAddress, Area, City, Country, Qualification and Email.
CREATE TABLE Employee ( EmpID INT PRIMARY KEY, EmpName VARCHAR(255), Mobile VARCHAR(20), PresentAddress VARCHAR(255), Area VARCHAR(255), City VARCHAR(255), Country VARCHAR(255), Qualification VARCHAR(255), Email VARCHAR(255) );
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Sql
- Insert multiple rows in a single MySQL query
- How to drop function in MySQL ?
- Change existing MySQL table column id to autoincrement
- Create Employee table in MySQL
- How to Rename column name in MySql ?
- Drop foreign id column (user_id) in MySQL
- How to get a list of MySQL views?
- Self join in mysql employee manager example
- How to create function in MySQL ?
- MySQL create procedure example
- How to check the MySQL version
- Clear the terminal screen in MySQL within the Windows powershell
- Get create table Query from existing table in phpMyAdmin
- How to create a new table from existing table in SQL
- How to retrieve data from two tables with one SQL statement
- Database connection using mySQLi with object-oriented
- Difference between SQL and NoSQL databases
- How to get the list of all constraints in MySQL database
- Get comma separated ids from table using MySQL
- Get number of connections being used by a specific user in MySQL
- Get data in random order with limit from table using mysql
- How to check column exists or not in table using MySQL
- Create Index in MySQL with example
- 1553 Cannot drop index 'posts_user_id_foreign': needed in a foreign key constraint
- How to get yesterday's date in MySQL ?