SQL学习笔记

关键词(联想、联想风暴):
database
table
column
show
select
from
where
having
and
or
in
between
insert
into
value
update
set
delete
order
by
asc
desc
distinct
as
like
union
join
left
right
inner
outer
full
create
table
int
varchar
null
not
unique
default
check
primary
foreign 
key
check
index
alert
auto
increment
view
isnull
isnotnull
基本语句(以句串词知语义):

select语句
select column_one as custum_name_one ,column_two as custom_name_two from table_name where condition;
select * from * union [all] select * from *;
select [*|distinct|into|top] ...;
condition:
	column_one=value_one and column_two=value_two
 	column_one=value_one or column_two=value_two <=> column in (value_one,value_two,...)
 	like '%G'
 	(select column_name from table_name where condition)

update语句
update table_name set column_one='value_one' ,column_two='value_two' ,... where condition;
update table_name
condition:
	column_one=value_one and column_two=value_two;
 	column_one=value_one or column_two=value_two <=> column in (value_one,value_two,...);
 	like '%G';
 	(select column_name from table_name where );

insert into语句
insert into table_name values(value_one ,value_two ,...);
insert into table_name(column_name_one ,column_name_two ,...) values(value_one ,value_two ,...);

delete语句
delete [*] from table_name where condition;

create table table_name
(
column_one data_type,
column_two data_type,
...
);

create [unique] index index_name 
on table_name(column_name);

create view view_name 
as select * from table_name where condition;

drop database database_name;
drop table table_name;
drop index index_name;
drop index table_name.index_name;
drop index index_name on table_name;
alter table table_name
drop index index_name;

group by column_name_one ,column_name_two ,...;
SELECT site_id, SUM(access_log.count) AS nums
FROM access_log GROUP BY site_id;

in (value_one ,value_two ,...);

order by column_name_one ,column_name_two ,....  [asc|desc]

truncate table table_name;

SELECT Websites.name, Websites.url, SUM(access_log.count) AS nums FROM (access_log
INNER JOIN Websites
ON access_log.site_id=Websites.id)
GROUP BY Websites.name
HAVING SUM(access_log.count) > 200;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值