Views 130213042135 Phpapp01
Views 130213042135 Phpapp01
• The view is a virtual table. It does not physically exist. Rather, it is created by a
query joining one or more tables.
• 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
• You can modify the definition of a VIEW without dropping it by using the following
syntax
CREATE OR REPLACE VIEW view_name
AS SELECT columns
FROM table
WHERE predicates;
A trigger is a block structure which is fired when a DML statements like Insert,
Delete, Update is executed on a database table. A trigger is triggered automatically
when an associated DML statement is executed.
• Syntax of Triggers
ALTER TRIGGER
trigger_name ENABLE;
Example
• Creating Trigger
def cube(x):
return x * x * x
def main():
x = cube(3)
print x
showMessage("Computation finished.")
print showMessage("Ready.")
main()
output:
baabtra@baabtra-desktop:~$ python ppt.py
27
Computation finished.
Ready.
None
Calling Functions
total = 0;
# Function definition is here
def sum( arg1, arg2 ):
# Add both the parameters and return them."
total = arg1 + arg2;
# Here total is local variable.
print "Inside the function local total : ", total
return total;
def main():
# Now you can call sum function
sum( 10, 20 );
print "Outside the function global total : ", total
main()
output:
baabtra@baabtra-desktop:~$ python
ppt2.py Inside the function local total : 30
Outside the function global total : 0
Advantage
• Indexes allow the database application to find data fast; without reading the whole
table
• An index can be created in a table to find data more quickly and efficiently
• The users cannot see the indexes, they are just used to speed up searches/queries
INDEX
• UNIQUE indicates that the combination of values in the indexed columns must be
unique
INDEX
• Rename an Index
The syntax for renaming an index is:
• Drop an Index
The syntax for dropping an index is:
• Types of Joins
LEFT JOIN: Return all rows from the left table, even if there are no matches in the
right table
RIGHT JOIN: Return all rows from the right table, even if there are no matches in
the left table
FULL JOIN: Return rows when there is a match in one of the tables
INNER JOIN
• The INNER JOIN keyword returns rows when there is at least one match in both
tables
• The LEFT JOIN keyword returns all rows from the left table (table_name1), even if
ther are no matches in the right table (table_name2)
• The FULL JOIN keyword return rows when there is a match in one of the tables
1)If an employee is entered with an employee_id value of 123, the database should not allow
another employee to have an ID with the same value
2)If you have an employee_rating column intended to have values ranging from 1 to 5, the
database should not accept a value of 6
Example
select insert_tbl_customer(201,'john','1990-10-5','b@gmail',94,true);
If this presentation helped you, please visit our page
facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us