--建立数据库
create database 库名
--删除数据库
drop database 库名
---使用一个数
据库
use 库名
--建立表
create table 表名
(
字段名1 varchar(20),
字段名2 int
)
---修改表 并增加字段
alter table 表名 add 字段3 datetime
---修改某一个字段的类型
alter table 表名 alter column 字段3 varchar(30)
--删除一个字段
alter table 表名 drop column 字段3
--删除表
drop table 表名
create table 表名
(
字段名1 int identity primary key, --自增主键
字段名2 varchar(200),
字段名3 datetime,
字段名4 text
)
--选择列
select
--数据来源
from
--过滤记录
where
--并且 相当于java的 &&
and
--或者 相当于java的 ||
or
--计算满足条件的记录个数
count(*)
--增加一条
insert into 表名( 字段1,字段2 )
values( 值1,值2 )
--修改记录
update 表名
set 字段1 = 值1,
字段2 = 值2
where 条件
--删除记录
delete from 表名
where 条件
-------------------------------------------------------
distinct 过滤重复的
avg 平均
sum总和
“子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。”
“=号换in”