Sql 增删改查
时间:2011-05-01 来源:段天狼
use master
go
if exists(select * from sysdatabases where name = 'userManager')
drop database userManager
go
create database userManager
go
use userManager
go
/***********用户表**********/
create table userInfo(
userId int identity not null,--用户ID
userName varchar(20) not null,--用户名
passWord varchar(20) not null,--密码
context varchar(20) --备注
)
go
alter table userInfo
add constraint PK_companyId primary key (userId)
go
/*************增**************/
insert into userInfo(userName, passWord, context)
values('乔峰','qiaofeng','备注1')
insert into userInfo(userName, passWord, context)
values('大黑','dahei','备注2')
insert into userInfo(userName, passWord, context)
values('小黄','xiaohuang','备注3')
insert into userInfo(userName, passWord, context)
values('大蓝','dalan','备注4')
go
/****************删除*****************/
delete from userInfo
where userName = '大黑';
GO
/****************修改*****************/
UPDATE userInfo
SET userName = '虚竹', passWord = 'xuzhu', context = '不会九阴白骨爪'
WHERE userName = '大黑';
GO
/****************查找*****************/
select userName, passWord, context
from userInfo
select * from userInfo
go
if exists(select * from sysdatabases where name = 'userManager')
drop database userManager
go
create database userManager
go
use userManager
go
/***********用户表**********/
create table userInfo(
userId int identity not null,--用户ID
userName varchar(20) not null,--用户名
passWord varchar(20) not null,--密码
context varchar(20) --备注
)
go
alter table userInfo
add constraint PK_companyId primary key (userId)
go
/*************增**************/
insert into userInfo(userName, passWord, context)
values('乔峰','qiaofeng','备注1')
insert into userInfo(userName, passWord, context)
values('大黑','dahei','备注2')
insert into userInfo(userName, passWord, context)
values('小黄','xiaohuang','备注3')
insert into userInfo(userName, passWord, context)
values('大蓝','dalan','备注4')
go
/****************删除*****************/
delete from userInfo
where userName = '大黑';
GO
/****************修改*****************/
UPDATE userInfo
SET userName = '虚竹', passWord = 'xuzhu', context = '不会九阴白骨爪'
WHERE userName = '大黑';
GO
/****************查找*****************/
select userName, passWord, context
from userInfo
select * from userInfo
相关阅读 更多 +