码迷,mamicode.com
首页 > 数据库 > 详细

SQL索引及视图常用语法

时间:2016-11-22 12:11:31      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:count   视图   drop   rom   form   class   view   log   from   

ALTER TABLE department  ADD INDEX dept_name_idx (name);
SHOW INDEX FROM department \G
ALTER TABLE department DROP INDEX dept_name_idx;
ALTER TABLE department ADD UNIQUE dept_name_index (name);
CREATE VIEW customer_vw (cust_id, fed_id, cust_type_cd, address, city, state, zipcode ) AS SELECT cust_id, CONCAT(ends in , substr(fed_id, 8, 4)) fed_id, cust_type_cd, address, city, state, postal_code FROM customer;
SELECT cust_type_cd, count(*) FROM customer_vw WHERE state = MA GROUP BY cust_type_cd ORDER BY 1;
SELECT cst.cust_id, cst.fed_id, bus.name FROM customer_vw cst INNER JOIN business bus ON cst.cust_id = bus.cust_id;
SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = bank ORDER BY 1;

 

SQL索引及视图常用语法

标签:count   视图   drop   rom   form   class   view   log   from   

原文地址:http://www.cnblogs.com/aguncn/p/6088495.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!