数据库程序设计1-5章实验

数据库程序设计1-5章实验,第1张

姚津泓实验作业 网页链接可以看看

--实验一

create database test1

on

(name=test1,

filename='d:\3116004357姚津泓\test1mdf',

size=10,

maxsize=50,

filegrowth=5)

log on

(name=test1_log,

filename='d:\3116004357姚津泓\test1ldf',

size=5mb,

maxsize=25mb,

filegrowth=5mb)

create database test2

on

(name=test11,

filename='d:\3116004357姚津泓\test11mdf',

size=10,

maxsize=50,

filegrowth=5),

(name=test22,

filename='d:\3116004357姚津泓\test22ndf',

size=10,

maxsize=50,

filegrowth=5),

(name=test33,

filename='d:\3116004357姚津泓\test33ndf',

size=10,

maxsize=50,

filegrowth=5)

log on

(name=test11_log,

filename='d:\3116004357姚津泓\test11ldf',

size=5mb,

maxsize=25mb,

filegrowth=5mb),

(name=test22_log,

filename='d:\3116004357姚津泓\test22ldf',

size=5mb,

maxsize=25mb,

filegrowth=5mb)

create database test3

on

(name=dab1,

filename='d:\3116004357姚津泓\dab1mdf',

size=10,

maxsize=50,

filegrowth=5),

filegroup fg11 --第一个文件组

(name=dab2,

filename='d:\3116004357姚津泓\dab2ndf',

size=10,

maxsize=50,

filegrowth=5),

filegroup fg22 --第二个文件组

(name=dat1,

filename='d:\3116004357姚津泓\dat1ndf',

size=10,

maxsize=50,

filegrowth=5),

(name=dat2,

filename='d:\3116004357姚津泓\dat2ndf',

size=10,

maxsize=50,

filegrowth=5),

filegroup fg33--第三个文件组

(name=daz1,

filename='d:\3116004357姚津泓\daz1ndf',

size=10,

maxsize=50,

filegrowth=5),

(name=daz2,

filename='d:\3116004357姚津泓\daz2ndf',

size=10,

maxsize=50,

filegrowth=5)

alter database test1

add file

(name=te,

filename='d:\3116004357姚津泓\tendf',

size=10,

maxsize=50,

filegrowth=5

)

alter database test2

modify file

(name=test11,

filename='d:\3116004357姚津泓\test11mdf',

maxsize=55

)

drop database test1

--实验2--

create database 实验

create schema yaojinhong

create table yaojinhong仓库

(

仓库号char(6)primary key check (仓库号like'[A-Z][A-Z][0-9][0-9][0-9][0-9]'),

城市char(10) unique not null,

面积 int check(面积>=50)

)

create table yaojinhong职工

(

职工号char(8)primary key check (职工号like'[A-Z][A-Z][0-9][0-9][0-9][0-9][0-9][0-9]'),

仓库号char(6)constraint ck foreign key references yaojinhong仓库(仓库号),

工资 money check (工资>=1000 and 工资<=10000)

)

create table yaojinhong供应商

(

供应商号 char(4)primary key check (供应商号like'[S][0-9][0-9][0-9]'),

供应商名 char(16),

地址char(30),

)

create table yaojinhong订购单

(职工号 char(8) not null foreign key references yaojinhong职工(职工号),

供应商号 char(4) null constraint supply foreign key references yaojinhong供应商(供应商号) on delete set null,

订购单号 char(6) primary key check(订购单号 like 'OR[0-9][0-9][0-9][0-9]'),

订购日期 datetime default getdate(),

金额 money default null

)

create table yaojinhong订购单明细

(订购单号 char(6) not null foreign key references yaojinhong订购单(订购单号),

序号 char(2),

产品名称 char(20),

单价 money default null check(单价>0),

数量 int not null check(数量>0),

primary key(订购单号,序号)

)

alter table yaojinhong订购单

add 完成日期 datetime default null

alter table yaojinhong订购单明细

add check(数量 between 0 and 1000)

alter table yaojinhong订购单明细

alter column 数量 int not null alter table yaojinhong供应商

alter column 供应商名 varchar(30)

实验3

insert into yaojinhong仓库 values('QW0001','广州',500)

insert into yaojinhong仓库 values('QW0002','上海',900)

insert into yaojinhong仓库 values('QW0003','北京',250)

insert into yaojinhong仓库 values('QW0004','纽约',1000)

insert into yaojinhong仓库 values('QW0005','深圳',650)

insert into yaojinhong职工 values('ZG000001','QW0005',3000)

insert into yaojinhong职工 values('ZG000002','QW0001',5600)

insert into yaojinhong职工 values('ZG000003','QW0004',6600)

insert into yaojinhong职工 values('ZG000004','QW0002',3800)

insert into yaojinhong职工 values('ZG000005','QW0005',3900)

insert into yaojinhong职工 values('ZG000006','QW0001',4600)

insert into yaojinhong职工 values('ZG000007','QW0003',4000)

insert into yaojinhong职工 values('ZG000008','QW0003',5000)

insert into yaojinhong职工 values('ZG000009','QW0002',4800)

insert into yaojinhong职工 values('ZG000010','QW0004',6000)

insert into yaojinhong供应商 values('S001','华广','深圳')

insert into yaojinhong供应商 values('S002','广工','广州')

insert into yaojinhong供应商 values('S003','美的','茂名')

insert into yaojinhong供应商 values('S004','乐视','深圳')

insert into yaojinhong供应商 values('S005','康佳','广州')

insert into yaojinhong订购单 values('ZG000007','S005','OR0001','2015-1-6',5000,'2015-2-5')

insert into yaojinhong订购单 values('ZG000002','S001','OR0002','2015-2-3',10000,'2015-3-4')

insert into yaojinhong订购单 values('ZG000003','S004','OR0003','2015-2-17',3000,'2015-5-16')

insert into yaojinhong订购单 values('ZG000006','S002','OR0004','2015-2-16',9000,'2015-4-18')

insert into yaojinhong订购单 values('ZG000010','S005','OR0005','2015-3-20',8000,'2015-6-27')

insert into yaojinhong订购单 values('ZG000001','S001','OR0006','2015-3-22',7500,'2015-7-29')

insert into yaojinhong订购单 values('ZG000006','S003','OR0021','2015-2-15',4600,'2015-10-13')

insert into yaojinhong订购单 values('ZG000004','S002','OR0007','2015-2-23',8500,'2015-8-29')

insert into yaojinhong订购单 values('ZG000003','S005','OR0008','2015-1-5',3600,'2015-11-11')

insert into yaojinhong订购单 values('ZG000001','S004','OR0009','2015-1-31',7600,'2015-12-14')

insert into yaojinhong订购单 values('ZG000007','S001','OR0010','2015-3-25',12000,'2015-7-30')

insert into yaojinhong订购单 values('ZG000008','S002','OR0011','2015-2-26',4600,'2015-9-27')

insert into yaojinhong订购单 values('ZG000010','S002','OR0012','2015-1-28',3400,'2015-11-21')

insert into yaojinhong订购单 values('ZG000009','S004','OR0013','2015-3-19',2300,'2015-10-24')

insert into yaojinhong订购单 values('ZG000007','S005','OR0014','2015-2-23',9000,'2015-9-21')

insert into yaojinhong订购单 values('ZG000008','S003','OR0015','2015-2-27',6400,'2015-12-23')

insert into yaojinhong订购单 values('ZG000002','S001','OR0016','2015-1-30',7900,'2015-6-30')

insert into yaojinhong订购单 values('ZG000005','S004','OR0017','2015-1-27',20000,'2015-8-18')

insert into yaojinhong订购单 values('ZG000009','S004','OR0018','2015-3-5',13000,'2015-7-31')

insert into yaojinhong订购单 values('ZG000004','S002','OR0019','2015-3-14',7000,'2015-6-17')

insert into yaojinhong订购单 values('ZG000006','S005','OR0020','2015-2-21',4300,'2015-5-25')

insert into yaojinhong订购单明细 values('OR0020','01','沐浴露',32,240)

insert into yaojinhong订购单明细 values('OR0001','02','洗衣粉',30,125)

insert into yaojinhong订购单明细 values('OR0012','03','洗衣液',39,59)

insert into yaojinhong订购单明细 values('OR0014','04','香皂',14,99)

insert into yaojinhong订购单明细 values('OR0004','05','盐',2,169)

insert into yaojinhong订购单明细 values('OR0005','06','酱油',14,65)

insert into yaojinhong订购单明细 values('OR0011','07','化妆品',26,24)

insert into yaojinhong订购单明细 values('OR0019','08','洗面奶',39,68)

insert into yaojinhong订购单明细 values('OR0008','09','面膜',5,147)

insert into yaojinhong订购单明细 values('OR0003','10','花生油',36,258)

insert into yaojinhong订购单明细 values('OR0017','11','鼠标',69,72)

insert into yaojinhong订购单明细 values('OR0015','12','鼠标垫',18,64)

insert into yaojinhong订购单明细 values('OR0016','13','移动电源',58,69)

insert into yaojinhong订购单明细 values('OR0012','14','插座',37,169)

insert into yaojinhong订购单明细 values('OR0011','15','牛奶',72,111)

insert into yaojinhong订购单明细 values('OR0020','16','洗洁精',9,114)

insert into yaojinhong订购单明细 values('OR0019','17','洁厕液',6,300)

insert into yaojinhong订购单明细 values('OR0010','18','鸡蛋',14,124)

insert into yaojinhong订购单明细 values('OR0009','19','牛肉',38,300)

insert into yaojinhong订购单明细 values('OR0016','20','内裤',59,654)

insert into yaojinhong订购单明细 values('OR0018','21','鞋子',299,300)

insert into yaojinhong订购单明细 values('OR0015','22','手表',890,34)

insert into yaojinhong订购单明细 values('OR0005','23','钱包',129,124)

insert into yaojinhong订购单明细 values('OR0008','24','行李箱',344,64)

insert into yaojinhong订购单明细 values('OR0014','25','手袋',3,874)

insert into yaojinhong订购单明细 values('OR0018','26','篮球',360,59)

insert into yaojinhong订购单明细 values('OR0003','27','足球',260,36)

insert into yaojinhong订购单明细 values('OR0005','28','羽毛球拍',78,69)

insert into yaojinhong订购单明细 values('OR0007','29','乒乓球拍',89,145)

insert into yaojinhong订购单明细 values('OR0020','30','羽毛球',5,645)

insert into yaojinhong订购单明细 values('OR0013','31','乒乓球',3,542)

insert into yaojinhong订购单明细 values('OR0016','32','牙膏',23,200)

insert into yaojinhong订购单明细 values('OR0009','33','牙刷',6,456)

insert into yaojinhong订购单明细 values('OR0019','34','防晒霜',56,65)

insert into yaojinhong订购单明细 values('OR0017','35','水杯',39,1187)

insert into yaojinhong订购单明细 values('OR0010','36','拖把',15,187)

insert into yaojinhong订购单明细 values('OR0004','37','扫把',6,200)

insert into yaojinhong订购单明细 values('OR0005','38','垃圾桶',16,254)

insert into yaojinhong订购单明细 values('OR0006','39','书',46,688)

insert into yaojinhong订购单明细 values('OR0016','40','卫生纸',13,500)

insert into yaojinhong订购单明细 values('OR0020','41','相机',3698,32)

insert into yaojinhong订购单明细 values('OR0013','42','手机',2000,200)

insert into yaojinhong订购单明细 values('OR0017','43','音响',500,143)

insert into yaojinhong订购单明细 values('OR0001','44','吸尘器',1688,40)

insert into yaojinhong订购单明细 values('OR0012','45','油烟机',3500,10)

insert into yaojinhong订购单明细 values('OR0010','46','台式电脑',4000,25)

insert into yaojinhong订购单明细 values('OR0013','47','空调',50,230)

insert into yaojinhong订购单明细 values('OR0005','48','电视机',1300,100)

insert into yaojinhong订购单明细 values('OR0016','49','洗衣机',3400,15)

insert into yaojinhong订购单明细 values('OR0011','50','笔记本',6000,20)

insert into yaojinhong仓库 values('QW0001','惠州',600)

原因:违反了PRIMARY KEY 约束'PK__仓库__530C599C7F60ED59'。不能在对象'yaojinhong仓库' 中插入重复键。语句已终止。

insert into yaojinhong职工 values('ZG000011','QW0009',3000)

原因:仓库号列参照仓库表的仓库号,此时在仓库表中找不到仓库号为QW0009的仓库。INSERT 语句与FOREIGN KEY 约束"FK__职工__仓库号__0AD2A005"冲突。该冲突发生于数据库"实验",表"yaojinhong仓库", column '仓库号'。

insert into yaojinhong仓库 values('QW0006','天津',30)

原因:在定义时,面积要大于等于50,这里面积为30,明显违反了用户定义完整性

delete yaojinhong仓库 where 城市='北京'

删除 *** 作失败。因为有职工参照了干记录

delete yaojinhong供应商 where 供应商号='S002'

因为删除参照完整性规则定义为set null

alter table yaojinhong职工

drop constraint ck

alter table yaojinhong职工

drop column 仓库号

alter table yaojinhong职工

add 仓库号 char(6)constraint ck foreign key references yaojinhong仓库

on delete cascade

on update cascade

update yaojinhong职工 set 仓库号='QW0006' where 职工号='ZG000002'

更新 *** 作失败,因为职工表所参考的仓库表中不存在仓库号为QW0006的仓库。

update yaojinhong仓库 set 仓库号=null where 仓库号='QW0001'

更新 *** 作失败,因为仓库号是关键字,不能为空。

update yaojinhong仓库 set 面积=30 where 仓库号='QW0001'

更新 *** 作失败,因为面积被定义约束大于或等于50,此处面积=30,显然违反了约束。

update yaojinhong职工 set 工资=(工资+(工资01))

update yaojinhong订购单 set 金额=(select SUM(单价数量) from yaojinhong订购单明细

where 订购单明细订购单号=订购单订购单号)

delete yaojinhong职工 where 仓库号 in (select 仓库号 from yaojinhong仓库 where 城市='北京')

delete yaojinhong订购单 where 供应商号 in (select 供应商号 from yaojinhong供应商 where 供应商名='广工')

实验4

1 select distinct 工资 from yaojinhong职工

select all 工资 from yaojinhong职工

2 select from yaojinhong仓库

3 select 职工号 from yaojinhong职工 where 工资>5000

4 select from yaojinhong仓库 where 仓库号 in(select 仓库号 from yaojinhong职工 where 工资>5000)

5 select 职工号 from yaojinhong职工 where 仓库号 in ('QW0005','QW0002') and 工资<5000

6 select from yaojinhong职工 where 工资 between 3000 and 5000

7 select from yaojinhong供应商 where 供应商名 like '%公司'

8 select from yaojinhong仓库 where 城市!='北京

9 select from yaojinhong订购单 where 供应商号 is null

10 select from yaojinhong订购单 where 供应商号 is not null

11 select from yaojinhong职工  order by 工资 ASC

12 select from yaojinhong职工  order by 仓库号 ASC,工资 DESC

13 select 职工号,城市 from yaojinhong职工  join yaojinhong仓库 on 职工仓库号=仓库仓库号 where 工资>6000

14 select 职工号,城市 from yaojinhong职工  join yaojinhong仓库 on 职工仓库号=仓库仓库号 where 面积>700

16 select from yaojinhong仓库  cross join yaojinhong职工

17 select from yaojinhong仓库  cross join yaojinhong职工

where 仓库仓库号=职工仓库号

18 select 供应商供应商号,供应商名,订购单号,订购日期 from yaojinhong供应商  join yaojinhong订购单

on 供应商供应商号=订购单供应商号

19 select 供应商供应商号,供应商名,订购单号,订购日期 from yaojinhong供应商 left join yaojinhong订购单

on 供应商供应商号=订购单供应商号

20 select 供应商供应商号,供应商名,订购单号,订购日期 from yaojinhong供应商 right join yaojinhong订购单 on 供应商供应商号=订购单供应商号

21 select 供应商供应商号,供应商名,订购单号,订购日期 from yaojinhong供应商 full join yaojinhong订购单 on 供应商供应商号=订购单供应商号

22 select 城市 from yaojinhong仓库 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 工资=3300)

23 select from yaojinhong仓库 where 仓库号 not in

(select 仓库号 from yaojinhong职工 where 工资<5000)

24 select from yaojinhong职工 where 工资 in

(select  工资 from yaojinhong职工 where 职工号='ZG000001')

and 职工号!='ZG000001'

25 select 城市 from yaojinhong仓库 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 职工号 in

(select 职工号 from yaojinhong订购单 where 供应商号 in

(select 供应商号 from yaojinhong供应商 where 地址='广州')))

26 select 供应商名 from yaojinhong供应商 join yaojinhong订购单 on 供应商供应商号=订购单供应商号 join yaojinhong职工 on 订购单职工号=职工职工号 join yaojinhong仓库 on 职工仓库号=仓库仓库号 where 地址='广州'and 城市='广州'

select 供应商名

from yaojinhong供应商 where 地址='广州' and 供应商号 in

(select 供应商号 from yaojinhong订购单 join yaojinhong职工 on 订购单职工号=职工职工号

join yaojinhong仓库 on 职工仓库号=仓库仓库号 where 城市='广州')

27 select 仓库号 from yaojinhong仓库 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 工资>any

(select 工资 from yaojinhong职工 join yaojinhong仓库 on 职工仓库号=仓库仓库号

where 仓库仓库号='QW0001')and 仓库号!='QW0001')

28 select 仓库号 from yaojinhong仓库 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 工资>all

(select 工资 from yaojinhong职工 join yaojinhong仓库 on 职工仓库号=仓库仓库号

where 仓库仓库号='QW0001'))

29 select from yaojinhong订购单 a where 金额=

(select MAX(金额) from yaojinhong订购单 b where a职工号=b职工号)

order by 职工号 ASC

30 select from yaojinhong仓库 where exists(select from yaojinhong职工 where 职工号 is null and 职工仓库号=仓库仓库号)

31 select from yaojinhong仓库 where not exists(select from yaojinhong职工 where 职工号 is null and 职工仓库号=仓库仓库号)

32 select COUNT(distinct 城市)城市数目 from yaojinhong仓库 where 城市 is not null

33 select SUM(工资)需要支付职工工资总数 from yaojinhong职工

34 select SUM(工资)北京和上海的仓库职工的工资总和 from yaojinhong职工 join yaojinhong仓库 on 职工仓库号=仓库仓库号

where 城市='北京' or  城市='上海'

35 select AVG(面积)平均面积 from yaojinhong仓库 where 仓库号 not in

(select 仓库号 from yaojinhong职工 where 工资<6000)

36 select max(金额)工资大于的职工所经手的订购单最高金额 from yaojinhong订购单 where 职工号 in

(select 职工号 from yaojinhong职工 where 工资>6000)

37 select 仓库号,AVG(工资)平均工资 from yaojinhong职工

group by 仓库号

38 select 仓库号,max(金额)最高金额,MIN(金额)最低金额,AVG(金额)平均金额 from yaojinhong职工 join yaojinhong订购单 on 职工职工号=订购单职工号 group by 仓库号

39 select 订购单订购单号,AVG(金额)平均金额 from yaojinhong订购单 join yaojinhong订购单明细  on 订购单订购单号=订购单明细订购单号

group by 订购单订购单号 having COUNT(订购单订购单号)>=5

40 select 仓库号,职工号,工资 from yaojinhong职工

order by 仓库号

compute avg(工资),sum(工资)by 仓库号

compute avg(工资),sum(工资)

41select 订购单明细订购单号,序号,产品名称,单价,数量,金额

from yaojinhong订购单明细 join yaojinhong订购单 on

订购单订购单号=订购单明细订购单号 order by 订购单订购单号

compute avg(金额),sum(金额)by 订购单订购单号

compute avg(金额),sum(金额)

42 select from yaojinhong订购单

compute avg(金额),sum(金额)

实验5

(1) 基于单个表按投影 *** 作定义视图。

create view yaojinhong仓库视图 as select from yaojinhong仓库

(2) 基于单个表按选择 *** 作定义视图。

create view yaojinhong仓库视图1 as select from yaojinhong仓库 where 城市='广州'

(3) 基于单个表按选择和投影 *** 作定义视图。

create view yaojinhong仓库视图2 as select 仓库号,面积 from yaojinhong仓库 where 城市='广州'

(4) 基于多个表根据连接 *** 作定义视图。

create view yaojinhong视图3 as select 职工号,城市,工资 from yaojinhong职工 join yaojinhong仓库 on 职工仓库号=仓库仓库号

(5) 基于多个表根据嵌套查询定义视图。

create view yaojinhong视图4 as select from yaojinhong仓库 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 工资>4000)

(6) 定义含有虚字段的视图。

create view yaojinhong虚字段视图(仓库号,城市,面积) as select 仓库号,城市,面积2 from yaojinhong仓库

2、分别在定义的视图上设计一些查询(包括基于视图和基本表的连接或嵌套查询)。

select from yaojinhong仓库视图

select from yaojinhong仓库视图1 where 城市='广州'

select 仓库号,面积 from yaojinhong仓库视图2

select 职工号,城市,工资 from yaojinhong职工 join yaojinhong仓库视图 on 职工仓库号=仓库视图 仓库号

select from yaojinhong仓库视图 where 仓库号 in

(select 仓库号 from yaojinhong职工 where 工资>4000)

3、在不同的视图上分别设计一些插入、更新和删除 *** 作,分情况讨论哪些 *** 作可以成功完成,哪些 *** 作不能完成,并分析原因。

insert into yaojinhong仓库视图(仓库号,城市) values('QW0008','长沙')

update yaojinhong仓库视图 set 面积=650 where 仓库号='QW0008'

insert into yaojinhong仓库视图 values('QW0008','长沙',500)

update yaojinhong仓库视图 set 面积=700 where 仓库号='QW0001'

delete yaojinhong仓库视图 where 仓库号='QW0008'

delete yaojinhong仓库视图 where 仓库号='QW0008'

估计时间: 2个小时

目标: 建立基本的MTA的配置的技能

试验的起点: 标准的Red Hat Linux安装

确保在Server1上的sednmailmc文件中的DAEMON_OPTIONS被注释并且重新编译sendmailcf文件使得能够接受来自其他主机的电子邮件。

介绍

本次实验作为一个安装和配置MTA的介绍。在介绍中我们将提及sendmail和postfix。您可以选择任何一个MTA,如果时间允许,您两个都可以做一下试验。在接下来的步骤中,您将

1 安装并且验证sendmail的“发件箱”

2 为您的sendmail的安装添加新的别名

3 使用m4工具来改变您的转发行为

4 安装POP3服务器并且配置POP客户端

在整个试验中,主机和域名取决于您的机器的IP地址。如果下面的试验出现了X字样的名称,您应该把X字样的名称替换成你的工作站的号码(您的IP地址的最后一个部分)。例如,如果您的工作站的IP的地址是19216802,您应该将stationXdomainXexamplecom转换成station2domain2examplecom。

将数据包过滤设定为无效状态。在本次试验开始之前,请您确保您的主机上的所有包过滤已被关闭(显然,在实际使用中您可以利用Linux内核的防火墙机制,然而我们在这里关掉它是为了减少潜在的问题)。

本次试验中以root身份来使用下面命令达成上面的要求:

service iptables stop

chkconfig iptables off

初始化安装-安装必要的软件包

下列软件包对于sendmail是必需的: sendmail,sendmail-cf,sendmail-doc,m4和procmail。对于postfix而言,您需要: postfix。如果需要他们,从CD上进行检视和安装,server1的NFS安装点,从: ftp://server1/pub/RedHat/RPMS/

为了安全的原因,sendmail和postfix的缺省的配置允许发邮件但是不允许从网络上接收邮件(缺省的它们只接受从回环接口上的连接)。按照如下配置您选择的MTA使得它接受传入的连接:

⑴ 对于sendmail: 修改 /etc/mail/sendmailmc使用dnl注释在下面的行之前,就像这样:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127001, Name=MTA')

⑵ 将您的sendmailcf文件做一个备份:

cp /etc/mail/sendmailcf /etc/mail/sendmailcforig

⑶ 在同一个目录下,编译sendmailcf

m4 /etc/mail/sendmailmc > /etc/mail/sendmailcf

⑷ 重新启动sendmail,通过

service sendmail restart

对于postfix:修改/etc/postfix/maincf

⑴ 找到并注释如下行

inet_interfaces = localhost

⑵ 取消注释该行:

inet_interfaces = all

⑶ 保存文件并且进行到步骤2 的结束的地方。找到和上面一样的对应于postfix的配置的地方。

对于sendmail: 有几个步骤您应该采用,以确保sendmail被正确安装。

⑴ 确信sendmail已经被在适当的运行级别上运行

检查您的sendmail被适当的配置且能够在重新启动以后其能够运行。使用chkconfig是比较方便的。

chkconfig -–list sendmail

sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off

如果sendmail在标准的用户运行级别时无效,使用chkconfig,ntsysv 或者serviceconf 之类的工具来激活服务。

⑵ 确定sendmail没有在启动的时候出现错误

Red Hat Linux安装的时候使用提供的syslog工具来记录所有的信息到文件/var/log/maillog中去。检查此文件中的最后出现“starting”的地方以确保sendmail在启动的时候没有任何错误。

sendmail可执行文件位于/usr/sbin/sendmail。为了确定sendmail是否正确标识您的主机名称,通过命令行开关开启其调试模式并且设定为0:

sendmail –d0 < /dev/null

Version 8116

Compiled with: LDAPMAP MAP_REGEX LOG MATCHGECOS MIME7TO8 MIME8TO7

NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS QUEUE SASL SCANF

SMTP TCPWRAPPERS USERDB

============ SYSTEM IDENTITY (after readcf) ============

(short domain name) $w = station2

(canonical domain name) $j = station2examplecom

(subdomain name) $m = station2

(node name) $k = station2examplecom

Recipient names must be specified

如果sendmail返回您的主机名称为localhost,您可能错误配置了/etc/hosts文件。检查您的/etc/hosts文件,删除所有的但记住留下localhost的指向。如果/etc/hosts文件是正确的,那么检查一下在/etc/sysconfig/netwoek中的HOSTNAME的定义。

试图向root@server1发送简单的邮件。您可以看到一个合理的您的主机的转发服务器的SMTP交换。

#echo “hello root” | mail –v –s hello root@server1

root@server1 Connecting to [127001] via relay

220 localhostlocaldomain ESMTP Sendmail 8128/8128; Mon, 22 Sep 2003 14:29:24 +0800

>>> EHLO localhostlocaldomain

250-localhostlocaldomain Hello station1 [127001], pleased to meet you

>>> MAIL From: SIZE=52 AUTH=root@localhostlocaldomain

250 210 Sender ok

>>> RCPT To:

>>> DATA

250 215 Recipient ok

354 Enter mail, end with "" on a line by itself

>>>

250 200 h8M6TOU5026513 Message accepted for delivery

root@192168241182 Sent (h8M6TOU5026513 Message accepted for delivery)

Closing connection to [127001]

>>> QUIT

221 200 localhostlocaldomain closing connection

如果SMTP交换向上面一样正确,那么消息将被转发到您的工作站上的本地的转发服务器上,并且mailq –Ac将会报告一个空的对列。接下来检查mail(不使用参数)来检查一下消息是否从本地的转发到server1。这样对列也应该是空的。

您的消息是不是在/var/log/maillog中正确的记录呢?在下面的步骤中,监视文件/var/log/maillog。下面的命令将会十分的有用:

xterm –e tail –f /var/log/maillog &

对于postfix:

⑴ 运行‘service sendmail stop’,接下来使用redhat-switch-mail使得postfix成为活跃的MTA。您也可以使用如下的命令行:

alternatives –set mta /usr/sbin/sendmailpostfix

⑵ 确保postfix在合适的运行级别有效:

chkconfig -–list postfix

postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off

⑶ 确定hostname命令正确的返回您的主机名称。应该是您的FQDN。

如果sendmail返回您的主机名称为localhost,您可能错误配置了/etc/hosts文件。检查您的/etc/hosts文件,删除所有的但记住留下localhost的指向,然后再试一遍。如果/etc/hosts文件是正确的,那么检查一下在/etc/sysconfig/netwoek中的HOSTNAME的定义。当这些值都正确的时候,启动postfix服务。

⑷ 确定postfix在启动的时候没有错误

和sendmail一样,Red Hat Linux的安装使用提供的syslog工具来记录所有的信息到文件/var/log/maillog中去。检查此文件中的最后查找任何错误信息。

试图向root@server1发送简单的邮件并且检查/var/log/maillog的记录文

mail –s `echo $USER` root@server1 < /etc/redhat-release

应该是如下所示:

Sep 22 02:51:50 station1 postfix/pickup[2865]: A20ED348389: uid=0 from=

Sep 22 02:51:50 station1 postfix/cleanup[3534]: A20ED348389: message-id=<2003092

2065150A20ED348389@station1examplecom >

Sep 22 02:51:50 station1 postfix/nqmgr[2866]: A20ED348389: from=<root@station1e span=""> </root@station1e>

xamplecom>, size=341, nrcpt=1 (queue active)

Sep 22 02:51:51 station1 postfix/smtp[3536]: A20ED348389: to=<root@1921682411 span=""> </root@1921682411>

82>, relay=192168241182[192168241182], delay=1, status=sent (250 Message q

ueued)

对于sendmail:

在sendmail决定消息的接受者的目的地的之前,其先试图在别名中查找。Sendmail的主要的别名配置文件是/etc/aliases。为了优化查找,sendmail为其别名记录建立了一个哈希表数据库/etc/aliasesdb该文件通过newalias命令产生(该命令是sendmail –bi的同名)

下列命令将增加用户student(如果不存在的话)

useradd student

在/etc/aliases 行加入如下的行:

me: student

wizards: root, me

methere: student@stationXexamplecom

现在运行newalias 命令来更新数据库,尝试发送邮件给您定义的收件人:

newalias

echo “hello there” | mail –s “hello” m

echo “hello there” | mail –s “hello” wizards

echo “hello there” | mail –s “hello” methere

您是否得到了期望的结果?是否所有的位于wizards的收件人都收到了邮件?如果没有,su – 到不是root的用户再试一次。

在postfix决定消息的接受者的目的地的之前,其先试图在别名中查找。Postfix的主要的别名配置文件是/etc/postfix/aliases。为了优化查找,postfix为其别名记录建立了一个哈希表别名数据库/etc/postfix/aliasesdb(和sendmail类似)该文件通过newalias命令产生。

下列命令将增加用户student(如果不存在的话)

useradd student

在/etc/postfix/aliases 行加入如下的行:

注意:注释root别名的那一行为postfix

me: student

wizards: root, me

methere: student@stationXexamplecom

现在运行newalias 命令来更新数据库,尝试发送邮件给您定义的收件人:

newalias

echo “hello there” | mail –s “hello” me

echo “hello there” | mail –s “hello” wizards

echo “hello there” | mail –s “hello” methere

您是否得到了期望的结果?是否所有的位于wizards的收件人都受到了邮件?

转发允许邮件通过使用中间的“转发”及其传递到其目的地。尽管这个功能曾经有用,但是转发已经成为Internet上垃圾邮件的源泉了。人们希望发送主动提供的的邮件的时候希望使用转发机制,从而使得邮件发源地很难被侦测出来。

下列步骤将使用下面的主机。替换X,Y和Z为适合的工作站的号码:

stationX:源机器,邮件从这里发出

stationY:转发机器,这里邮件从发送者送出

stationZ:目的机器,邮件的最终目的

该步骤假设您是stationX,转发机器,与某人的stationY合作,该机器为邮件的源头。在该步骤中,注意/var/log/maillog的变化。下列命令将会显得十分的有用。

对于sendmail

步骤⑴ :允许转发

您具有控制允许谁在您的机器上转发的能力。通过控制您的机器的混杂转发,您可以使得任何人都能够将您的机器作为转发的主机。(我们对于这种的尝试表示反对,也希望通过该实验显示出其缺陷)。配置/etc/mail/sendmailmc, 通过加入如下行使得m4前置处理器允许混杂转发:

/etc/mail/sendmailmc

(…其他的内容…)FEATURE(promiscuous_relay)dnl

使用m4前置处理机通过这个模板文件生成一个新的sendmail配置文件,然后将新生成的文件与通过sendmail RPM软件包提供的进行比较

m4 /etc/mail/sendmailmc > /etc/mail/sendmailtest-relay

diff /etc/mail/sendmailtest-relay /etc/mail/sendmailcf

使用混杂转发以后会有多大的不同呢?现在将新建立的sendmailtest放置在恰当的位置上,重新启动sendmail

mv /etc/mail/sendmailcf /etc/mail/sendmailcfaccept-mail

cp /etc/mail/sendmailtest-relay /etc/mail/sendmailcf

service sendmail restart

让您的伙伴扮演恶意的垃圾邮件的发送者,该人能够通过telnet到您的机器上的smtp(sendmail)的25号断口,进行垃圾邮件发送地址的欺骗,在stationY键入如下命令:

这个例子对于stationY(源机器) station2,并且stationX(转发,在这里目的机器) station1

[root@station1 root]# telnet station1 25

Trying station1examplecom

Connected to station1examplecom (station1examplecom)

Escape character is '^]'

220 station1examplecom (IMail 800 8-1) NT-ESMTP Server X1

helo mailcrackerorg

250 hello station1examplecom

mail from: spammer@crackerorg

250 ok

rcpt to:root@station1examplecom

250 ok its for root@mailgridodsorg

data

354 ok, send it; end with

Subject: Faked

this was faked!

250 Message queued

quit

221 Goodbye

Connection closed by foreign host

垃圾邮件现在送到您的机器上了。下一步,看看您的伙伴能不能从您的机器转发给第三台机器:

这个例子对于stationY(源机器) station2,并且stationX(转发,在这里目的机器) station1,并且stationZ(目的机器) station3

[root@station1 root]# telnet station1 25

Trying station1examplecom

Connected to station1examplecom (station1examplecom)

Escape character is '^]'

220 station1examplecom (IMail 800 9-1) NT-ESMTP Server X1

helo mailcrakerorg

250 hello station1examplecom

mail from: spammer@crakerorg

250 ok

rcpt to root@station3examplecom

250 ok its for root@station3examplecom

data

354 ok, send it; end with

Subject: Relayed

this was faked any relayed!

250 Message queued

quit

221 Goodbye

Connection closed by foreign host

由于您的机器已经被配置成为允许混杂转发,垃圾邮件可以通过您的机器进行邮件转发。

对于postfix:

您具有控制允许谁在您的机器上转发的能力。缺省的postfix允许在子网上的任何人通过您的机器进行转发。但是并不是在每一个环境中都安全的。例如,您的机器和其他机器在一起,如果您的本地子网里有一台机器被其他人控制,那么其他的机器都会有麻烦。

让您的伙伴扮演恶意的垃圾邮件的发送者,该人能够通过telnet到您的机器上的postfix的25号断口,进行垃圾邮件发送地址的欺骗,在stationY键入如下命令:

[root@station1 root]# telnet station1 25

Trying 127001

Connected to station1 (127001)

Escape character is '^]'

220 station1examplecom ESMTP Postfix

helo mailcrakerorg

250 station1examplecom

mail from:spammer@crakerorg

250 Ok

rcpt to: root@station1examplecom

250 Ok

data

354 End data with

Subject: Faked

this was faked!

250 Ok: queued as 4FFA2348389

quit

221 Bye

Connection closed by foreign host

垃圾邮件现在送到您的机器上了。下一步,看看您的伙伴能不能从您的机器转发给第三台机器:

这个例子对于stationY(源机器) station2,并且stationX(转发,在这里目的机器) station1,并且stationZ(目的机器) station3

[root@station1 root]# telnet station1 25

Trying 127001

Connected to station1 (127001)

Escape character is '^]'

220 station1examplecom ESMTP Postfix

helo mailcrakerorg

250 station1examplecom

mail from: spammer@crackerorg

250 Ok

rcpt to: root@station3examplecom

250 Ok

data

354 End data with

subject: Relayed

this was faked and relayed!

250 Ok: queued as 69C7B348389

quit

221 Bye

Connection closed by foreign host

由于您的机器已经被配置成为允许混杂转发,垃圾邮件可以通过您的机器进行邮件转发。

步骤⑵ :不允许转发

对于sendmail

通过替换新的sendmailcf为接受传入的信件的配置文件来恢复缺省的sendmail的配置,并且重新启动sendmail:

mv /etc/mail/sendmailcfaccept-mail /etc/mail/sendmailcf

service sendmail restart

让您的伙伴再从stationY转发垃圾邮件。您的sendmail还是一个转发器么?任何一个转发的都会产生如下的消息:

550 root@station3examplecom Relaying denied

对于postfix

编辑文件/etc/postfix/maincf取消转发。

查找并且取消注释下面的行,并且重新启动postfix

mynetworks_style = host

让您的伙伴再从stationY转发垃圾邮件。您的postfix还是一个转发器么?任何一个转发的都会产生如下的消息:

554 : Recipient address rejected: Relay access denied

步骤⑶ :选择性的转发

对于sendmail

对于特定的主机,域或者网络,编辑/etc/mail/access并且重新启动sendmail。为了允许所有在examplecom域中的机器可以把您的机器作为邮件转发服务器,你在/etc/mail/acces中添加如examplecom域。和您的伙伴使用场景A中的命令进行测试。

对于postfix

对于特定的主机,域或者网络,编辑/etc/postfix/maincf并且重新启动postfix。对于特定的主机允许通过您的机器进行转发,找到并且取消注释该行:

mynetworks_style = host

然后添加新行来允许转发的主机和网络,在这里允许station1和本地转发

mynetworks = 19216801, 127000/8

和您的伙伴使用场景A中的命令进行测试。

在这个步骤中,你将配制您的机器stationX作为邮件的POP3服务器,使得您的在stationY的伙伴扮演POP客户端的角色。

步骤⑴ :安装POP3服务器

配置一个POP3服务器比较简单,只需要两个步骤:

① 安装相关的RPM软件包

② 在xinetd中允许服务

① 安装相关的RPM软件包

POP守护进程和其他的具有相同功能的守护进程,例如IMAP守护进程绑定在软件包imap中。再如xinetd,krb5-libs和imap软件包来检查imap软件包含有什么软件。

三个守护进程被包括进来:imapd,ipop2d和ipop3d。POP3被用在很多Internet服务提供商,POP2提供是为了向后兼容。IMAP守护进程提供了根加复杂的能力,包括了在服务器端的文件夹的管理。

② 在xinetd中允许服务

对于本实验,我们仅选定POP3服务。ipop3d通过xinetd在请求的时候被启动。为了激活,运行下面的命令:

service xinetd start

chkconfig ipop3 on

查看一下/etc/xinetdd/ipop3。显式的重新启动xinetd并不是必需的,由于chkconfig发送给xinetd 一个USR2信号告诉他重新调入其配置。

确认服务

运行下面的命令确认服务已经被正确的安装。下面的命令只是一个指导:

echo “mail to be poped” | mail –s “Hello student” student

[root@station1 root]# telnet localhost 110

Trying 127001

Connected to station1 (127001)

+OK POP3 station1 v200178rh server ready

USER student

+OK User name accepted, password please

PASS student

+OK Mailbox open, 1 messages

list

STAT

+OK 1 440

TOP 1 99999

retr 1

+OK Top of message follows

Return-Path: root@station1examplecom

Delivered-To: student@station1examplecom

Received: by station1examplecom (Postfix, from userid 0)

id 72314348390; Mon, 22 Sep 2003 08:02:27 -0400 (EDT)

To: student@station1examplecom

Subject: Hello student

Message-Id: 2003092212022772314348390@station1examplecom

Date: Mon, 22 Sep 2003 08:02:27 -0400 (EDT)

From: root@station1examplecom (root)

Status:

mail to be poped

DELE 1

+OK Message deleted

QUIT

+OK Sayonara

Connection closed by foreign host

如果一切顺利的话,您现在有一个安装好的POP服务器了。

步骤⑵ :使用POP客户端

所有的现在的邮件用户代理(MUA),例如netscape,elm,Outlook,pine和mutt都是使用POP的,可以被用作POP的客户端。每一个的配置都有所不同。同样有一个流行字符界面的的POP客户端叫做fetchmail。fetchmail是高度的可配置的,可以查询多个邮箱,可以作为守护进程运行,这样使得其每五分钟查询用户的邮箱。fetchmail在主机上递送邮件到邮件传送代理(MTA),例如sendmail。我们将勾画出以后如何安装fetchmail和使用其来查询我们装过的POP服务器。

从CD或者从 ftp://server1/pub/RedHat/RPMS来安装fetchmail软件包

注意到有很多选项可以影响fetchmail的行为。建立一个~/fetchmailrc文件如下所示:

~student/fetchmailrc

poll stationXexmaplecom with protocol pop3: user studentXX there is user studentXX here password “password”

由于密码存储在该文件中,因此fetchmail将会拒绝运行除非您把该文件的属性设定为对于仅仅文件的所有者只读。注意还可以使用chown改变由root创建的文件的所有者为studentXX。

chmod 600 ~student/fetchmailrc

chown studentstudent ~student/fetchmailrc

尝试使用studentXX登陆到POP3邮

echo “hello student” | mail –s “Hola” student

su – student

fetchmail –v

exit

fetchmail能不能接收到student的POP邮件?将递送student的邮件到哪里?比从本地获取POP邮件有意义么?

让您的伙伴在另外一台机器上建立相同的~/fetchmailrc文件(或者配置其它诸如mozilla的MTA)试图从您的服务器上进行收信。

⑴ m4宏语言提供给sendmail管理哪些东西?把所有的在xyzcom的用户邮件导向到本地用户xzplogin该使用什么语法?该在什么文件的和处填上这句话?

⑵ mailq命令用来作什么?您如何使用?

⑶ 当命令sendmail –q发出以后,sendmail将会试图仍在队列中等待的邮件。何时使用该命令是有用的?

⑷ 如果去除FEATURE(accept_unresolvable_domains)的注释将对垃圾邮件产生如何的影响?

⑸ m4有什么特征允许sendmail发送邮件作为整个域(例如,“examplecom”)而不是完全的符合标准的主机名称(例如,“mailexamplecom”)?

⑹ 在postfix中mynetworks_style如何影响转发?

请您查看文件/etc/postfix/maincf。

⑺ 在文件/etc/postfix/access中需要如何的活跃的变化?

由于是采用全英语的教学材料,并大量涉及采用英语教学的教学模式,建议学生们在开始正式上课之前先掌握一定的财务英语词汇,会更有利于后期的学习。

ACCA英语要求

ACCA专业资格考试全世界统一标准,教材、试卷、答题全用英语,所以学习ACCA最好有大学英语考试四级的英文程度(至P阶段则基本要求大学英语考试六级以上),当然这也是因人而易的。所以建议想报名ACCA的学员先看看教材、财务英语等,作为一个有雄心考ACCA的大学生来说,你没有雄心考英语四、六级有点说不过去吧。

从2001年起,ACCA对报考ACCA专业资格考试的人员的英语水平没有硬性要求,即不要求提供英语水平证书,只要申请人认为自己的英语水平可以胜任ACCA的考试就可以。但是,如果学员在注册时选择参加牛津布鲁克斯大学(即OBU)学位项目(即希望在通过前9门课程后申请该大学的应用会计理学士学位),在申请该大学学士学位时应按要求提供ACCA认可的英语水平证明,如CET-6、TOEFL、GMAT或IELTS证书等。

ACCA英语答题考试难度如何

ACCA考试难度是阶梯式的。基础阶段accaF1至accaF3,学名又叫“Knowledge”阶段,就是从零开始的会计和管理学科的ABC,没有任何专业知识背景,理论上讲:只要具有高中毕业以后的英语水平的学员都是可以胜任ACCA(因为第一阶段涉及到的会计类和管理类的单词都是基础阶段的,比如说Financial Statement—财务报表,Assets-资产都非常容易理解)。

第二阶段的课程有六门(accaF4-accaF9),知识方面也是循序渐进的。两门纯粹考理论的F4和F8,没有任何的计算。其中F4是以大量的记忆为主的(因为是法律方面的课程)。所以,非常具有记忆的性质(法律条文相对来说要的是语言的严谨)。F8的课程和F4很相像,因为审计也是强调程序和方法,以及流程图表的。所以,学习方法基本类似。

F5、F6、F7、F9都是计算部分占比较大比例的考试科目。中国学生向来喜欢计算题——一是做题的速度很快,二是准确度很高。所以 第二阶段课程平均通过率是70%左右。ACCA的P阶段的课程是专业界段的课程,对大家综合应用英语的能力提出了新的挑战。

从以上来看,无论是学习ACCA还是报考ACCA,都不用担心自己英语水平不能通过ACCA考试,况且ACCA虽然有13门课程,但知识内容都是由浅入深,循序渐进的进行,即使非会计专业学员也能很好理解每科知识点,加以复习、记忆、练习等学习流程,那你还会害怕ACCA不手到擒来吗

急速通关计划 ACCA全球私播课 大学生雇主直通车计划 周末面授班 寒暑假冲刺班 其他课程

以上就是关于数据库程序设计1-5章实验全部的内容,包括:数据库程序设计1-5章实验、5.30 电子邮件sendmail试验、怎么学英语等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10139153.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存