首页 > 数据库技术 > 详细

常用sql

时间:2020-03-07 23:52:20      阅读:105      评论:0      收藏:0      [点我收藏+]

一.基础

create/drop  database dbname / table tbname(新建/删除数据库、表)

alter table tbname add 字段名 类型

create  index indexname on tbname(字段名) 创建索引

drop index indexname 删除索引

增删改查:

insert into tbname (字段a,字段b) values(a,b)

delete from tbname where id =‘1‘

update table set 字段= a where id=‘1’

 select * from tbname

count,sum,avg,max,min

select distinct * from tbname order by id desc 去重复、倒序

筛选条件 where and ,having,group by,in,not in,not exists, select top 10 * from tbname,随机select newid(),order by newid()

 

多表查询

select * from tba a left join tbb b on a.id=b.id

right join on

select * from tba where a in (select * from tbb)

 

常用sql

原文:https://www.cnblogs.com/oo-llm/p/12439107.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!