SQLServer的增删改查
t-sql常用语句
创建数据库:
create database [数据库名]
create database [school]
删除数据库:
drop database [数据库名]
drop database [school]
创建表:
create table [表名]([列名] [类型](长度) 设置,列名 类型(长度) 设置)
create table [student] ( [name] [varchar](11) identity(1,1) , [id] [int](11) not null)
删除表:
drop table [表名]
drop table [mytest];
增加列:
alter table [表名] add 列名 设置
alter table [student] add commission money null
删除列:
alter table [表名] drop column [要删除列];
alter table [student] drop column [test];
添加行:
insert into [表名](列名) values (值);
insert into [grade](gradename) values ('h1');
删除行:
delete from [表名] where [gradeid]>=4;//条件
delete from [grade] where [gradeid]>=4;
更新行中数据:
update [表名] set [要修改列]=要修改值 where [gradeid]=8;//条件
update [grade] set [gradename]='test' where [gradeid]=8;
查询数据:
显示所有:
select *from 表名;
select *from grade;
显示部分:
select [列名],[列名] from [查询表];
select [studentno],[studentname] from [student];
显示含空值:
select *from [查询表] where [列]is null;//is null 是否 is not null不是空
select *from [student] where [studentname]is null;
限制显示行:
select top 3 *from [表名];//top 值:显示多少行
select top 3 *from [student];
上一篇: 你可能还不知道的关于JavaScript类型的细节?
下一篇: 搜索引擎 判断你的网站SEO作弊