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';

 

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