SQL筆記(1)

SQL筆記(1) 

--SQL筆記(1)
-- 如果觸發非唯一性約束,該操作爲替換操作,否則爲插入操作
-- replace into users values(1,'tom','123456'); 

-- 如果觸發非唯一性約束,該插入操作會被阻止
-- insert ignore users values(2,'tom','123456');

-- create table as select創建和查詢相同結構的表  case when then else end 類似多重邏輯判斷 if.. ELSE IF... 
-- create table userss  as select   
-- case name												
-- when name='tom' then 'marry'
-- else name end,password from users;

-- force index 強制使用索引
-- select * from users FORCE INDEX(ns);  

-- on duplicate key update 存在更新 不存在插入
-- insert into users(id,name,password) values(4,'4','123456') on duplicate key update name='tom';

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章