Mysql - 使用入门 (12)

更新可以先删除视图再创建,也可以直接使用create or replace view 更新视图

CREATE OR REPLACE VIEW productcustomers AS SELECT cust_name, prod_id FROM customers, orders, orderitems WHERE customers.cust_id = orders.cust_id AND orderitems.order_num = orders.order_num; 18.1用视图重新格式化检索出的数据 CREATE VIEW vendorlocations AS SELECT CONCAT( RTRIM( vend_name ), '(', RTRIM( vend_country ), ')' ) AS vend_title FROM vendors ORDER BY vend_name; SELECT * from vendorlocations; 18.1用视图过滤不需要的数据 CREATE VIEW customeremail AS SELECT cust_id, cust_name, cust_email FROM customers WHERE cust_email IS NOT NULL; SELECT * FROM customeremail; 18.1用视图计算字段 CREATE VIEW orderitemsexpanded AS SELECT order_num, prod_id, quantity, item_price, quantity * item_price AS expanded_pricce FROM orderitems; SELECT * FROM orderitemsexpanded; 19.0使用存储过程 20.0使用游标 21.0使用触发器 22.0管理事物处理 23.0安全管理 24.0数据库维护 25.0优化性能

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpzyzd.html