SQL Chapter5

Create database SQLTest4

Create table Student (
	SNO CHAR(15),
	SNAME CHAR(15),
	SSex CHAR(5),
	Sdept CHAR(5)
)

Create table Course (
	CNO INT,
	CNAME CHAR(8),
	Cpno INT,
	Ccredit INT
)

Create table SC (
	Sno Char(15),
	Cno int,
	Grade int
)


-----------------------------------------


Create View SC_View
As 
Select Sno,Cno,Grade 
From SC
Where Cno = 1
And Cast(DATENAME(hh,GETDATE()) As int) Between 9 And 17
And DATENAME(WEEKDAY, GETDATE()) in ('星期一','星期二','星期三','星期四','星期五')
With Check Option;

Create View IS_Student1
As 
Select Sno,Sname,Ssex,Sdept
From Student
Where Sdept = 'IS'
With Check Option;

Create View IS_Student2
As 
Select Sno,Sname,Ssex,Sdept
From Student
Where Sdept = 'IS'


select * from is_student1
select * from is_student2

insert into IS_Student1
values('2012215121','李勇','男','CS');

insert into IS_Student2
values('2012215121','李勇','男','CS');

在这里插入图片描述
在这里插入图片描述

drop user 张勇
drop login zhangyong
create login zhangyong with password='123';
create user 张勇 for login zhangyong;
create login litianming with password='123';
create user 李天明 for login litianming;


Grant Insert
On Student
To 张勇
With Grant Option

Grant Update(Cpno),Select
On Course
To 李天明

--把对表S的INSERT权限授予用户张勇,并允许他再将此权限授予其他用户。
--把查询SPJ表和修改QTY属性的权限授给用户李天明。


--把对表S的INSERT权限授予用户张勇,并允许他再将此权限授予其他用户。
--把查询SPJ表和修改QTY属性的权限授给用户李天明。

在这里插入图片描述

Insert Into Student Values('95001','李勇','男',20,'CS');
Insert Into Student Values('95002','刘晨','女',19,'IS');
Insert Into Student Values('95003','王敏','女',18,'MA');
Insert Into Student Values('95004','张立','男',19,'IS');

Insert Into Course Values(1,'数据库',5,4);
Insert Into Course Values(2,'数学',NULL,2);
Insert Into Course Values(3,'信息系统',1,4);
Insert Into Course Values(4,'操作系统',6,3);
Insert Into Course Values(5,'数据结构',7,4);
Insert Into Course Values(6,'数据处理',NULL,2);
Insert Into Course Values(7,'PASCAL语言',6,4);

Insert Into SC values('201215121',1,92);
Insert Into SC values('201215121',2,85);
Insert Into SC values('201215121',3,88);
Insert Into SC values('201215122',2,90);
Insert Into SC values('201215122',3,80);

Alter Table Course Alter Column Cname Char(20)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值