A VIEW is created by SELECT statements.
SELECT statements are used to take data from the source table.
Syntax:
CREATE [OR REPLACE] VIEW view_name AS
SELECT columns
FROM tables
[WHERE conditions];
Examples:
Basic table
select Code,Transactionhead,Ishavesubgroup from transactionhead
Result:
Create View
Create view grouphead as
Select Code,Transactionhead from Transactionhead
Result:
Syntax Select view:
SELECT * FROM view_name;
Examples:
select * from grouphead
Result:
MySQL alter VIEW:
Syntax:
ALTER VIEW view_name AS
SELECT columns
FROM table
WHERE conditions;
Examples:
Alter View grouphead as select Code,TransactionHead from
Transactionhead where IsHaveSubGroup=1
Result:
MySQL Drop VIEW:
Syntax:
DROP VIEW [IF EXISTS] view_name;
0 Comments