SQL笔记(一)

create database studentbd2
on primary 
(name=studentbd2,
filename='F:\database\student2mdf.mdf',
size=5,
maxsize=10,
filegrowth=10%)
log on
(name=student2log,
filename='F:\database\student2_log.ldf',
size=2,
maxsize=5,
filegrowth=10%)
use studentbd2
go
create table 学生表
(
学号 char(9) not null constraint pk_stuid primary key,
姓名 varchar(8) not null constraint unq_stuname unique,
性别 bit constraint de_sex default 0,
总分 float constraint ck_zf check(总分>=0)
)
create table 课程表
(
课程号 char(9) not null constraint pk_coursid primary key,
课程名 varchar(20) not null constraint unq_coursename unique,
学时 int constraint ck_xueshi check(学时>=0),
学分 int constraint ck_xuffen check(学分>=0)
)
create table 选课表
(
学号 char(9) not null constraint fk_student_xk foreign key references 学生表(学号),
课程号 char(9)not null constraint fk_course_xk foreign key references 课程表(课程号),
成绩 numeric(4,1) constraint ck_chengji check(成绩<=100 and 成绩>=0),
constraint pk_xk primary key(学号,课程号)
)

create table 图书表
(
编号 int identity(1001,1) not null constraint pk_bh primary key,
索书号 char(9) not null constraint ubiq_ssh unique,
)

insert into 图书表 values ('s10101'),('s12212')
select * from 图书表

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值