首页 > 代码库 > SQL索引及视图常用语法
SQL索引及视图常用语法
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索引及视图常用语法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。