一:数据定义创建操作
1.在d盘数据库文件夹下创建一个仓库库存管理的数据库。
create database 仓库库存管理 on ( name=kucum, filename='d:\数据库\kucum.mdf', size=50, filegrowth=2 ) log on ( name=kucum_log, filename='D:\数据库\kucum_log.ldf', size=25, filegrowth=3 )
create table 工作人员表 ( 人员编号 char(10), 姓名 char(6), 性别 char(2), 出生日期 datetime ) create table 客户表 ( 客户编号 char(10), 客户名称 char(20), 客户年龄 int, 城市 char(10) ) create table 库存零件表 ( 零件编号 char(10), 零件名称 char(30), 数量 int, 颜色 char(10), 重量 int ) create table 进货单表 ( 进货单号 char(10), 进货时间 datetime, 零件编号 char(10), 客户编号 char(10), 人员编号 char(10), 数量 int ) create table 出货单表 ( 出货单号 char(10), 出货时间 datetime, 零件编号 char(10), 客户编号 char(10), 人员编号 char(10), 数量 int )
增加一列
alter table 工作人员表 add 职务 char(6)删除一列
alter table 客户表 drop column 客户年龄
alter table 表名
alter column 属性 类型
4对行的操作
插入一行两种方法
(1)
insert into 工作人员表
values('20091205','王晓亮','男','1983-02-06','工作')
(2)
insert into 工作人员表(人员编号,姓名, 性别, 出生日期, 职务)
values('20091205','张高辉','男','1983-02-06','工作')
删除一行;
delete from 出货单表
where
出货时间<'1996-01-01'
update 出货单表
set 数量=数量+8
where 出货单号