Software Testing

k2G9Eo9
RdZQRt6

Popular Posts

VIEW

A VIEW is not a physical table, but rather, it is VIEW is a virtual table. If he VIEW already exists, the CREATE VIEW statement will return an error.

Why views?

  • Views can be effective copies of base tables.
  • Views can have column names and expressions.
  • You can use any clauses in views.
  • Views can be used in INSERT/UPDATE/DELETE.
  • Views can contain expressions in the select list.
  • Views can be views of views.

Restrictions on the View definition

  • The SELECT statement cannot contain a subquery in the FROM clause.
  • The SELECT statement cannot refer to system or user variables.
  • Within a stored program, the definition cannot refer to program parameters or local variables.
  • The SELECT statement cannot refer to prepared statement parameters.
  • Any table or view referred to in the definition must exist.
  • The definition cannot refer to a TEMPORARY table, and you cannot create a TEMPORARY view.
  • Any tables named in the view definition must exist at definition time.
  • You cannot associate a trigger with a view.
  • Aliases for column names in the SELECT statement are checked against the maximum column length of 64 characters (not the maximum alias length of 256 characters).

  • Basic syntex:
CREATE VIEW View_Name AS SELECT * FROM Table_Name ;
Syntax For MySQL:
CREATE VIEW dept AS SELECT * FROM department;
After Execution: 
(0 row(s) affected)
(0 ms taken)
You can check created VIEW table by using these Syntex:
show tables
Result:
Tables_in_DB_Name
Table1
Table2
Table3
Table4
dept

No comments:

Post a Comment