MySql优化

1.索引失效原因

1.全值匹配
2.最佳左前缀法则

2.Orcale自增ID

CREATE TABLE testTable1
(
ID INT NOT NULL,
NAME VARCHAR2(4000) NOT NULL,
PRIMARY KEY(ID)
);

-- 创建序列  
CREATE SEQUENCE te11stTable1_ID_SEQ MINVALUE 1 NOMAXVALUE INCREMENT BY 1 START WITH 1 NOCACHE;

-- 创建触发器   
CREATE OR REPLACE TRIGGER testTable1_INS_TRG BEFORE INSERT ON testTable1 FOR EACH ROW WHEN(NEW.ID IS NULL)
BEGIN
SELECT testTable1_ID_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
END;

3.Oracle去重复

SELECT DISTINCT asn.MCID FROM MVVW_ASN asn where asn.MCID is not null

你可能感兴趣的:(MySql优化)