关键词(联想、联想风暴):
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;