实验一 SQL定义子语句实验

老师要求我们每个人的数据库名字不一样,在这里我用的就是加上我的学号.

# 代码仓库
https://gitee.com/njit-wlk/njit-database

use master
create database pay205191028
on (Name=pay1
,Filename=‘D:\Program Files\SQL\paydata1.mdf’
,Size=10
,Maxsize=100
,FileGrowth=5%)
LOG ON (Name=pay3
,Filename=‘D:\Program Files\SQL\paylog.ldf’
,Size=5
,Maxsize=25
,FileGrowth=10)
请填写完成该要求的alter database 语句
ALTER database pay205191028 add file
(Name=pay2
,Filename=‘D:\Program Files\SQL\paydata2.ndf’
,Size=5
,Maxsize=20
,FileGrowth=2)

USE pay205191028
Create Table pay205191028.dbo.dept
(DeptNo varchar(10) Not Null Unique
,DeptName varchar(20) Not Null)

请填写创建person表的语句

USE pay205191028
Create Table pay205191028.dbo.person
(No char(6) not null primary key
,Name char(10) not null
,Sex char(2) not null
,Birthday datetime null
,Professor varchar(12) null
,DeptNo varchar(10) not null foreign key(DeptNo) REFERENCES dept(DeptNo));

请填写创建pay表的语句
USE pay205191028
Create Table pay205191028.dbo.pay
(No char(6) not null,
Year int not null,
Month int not null,
Base decimal(5,1),
Bonus decimal(5,1),
Deduct dec(5,1)
,Fact as Base+Bonus-Deduct);

利用SQL创建索引
create index sort_name On person (Name);
create index sort_yearmonth on pay(year,month);
create unique index sort_deptname on dept(Deptname);
create clustered index sort_no on pay(No);

利用SQL语句删除索引
Drop index pay.sort_no;

最后祝大家顺利完成第一次实验

你可能感兴趣的:(南工程数据库实验,sql)