【摘要】 –创建数据库
create database jxgl
on
(name=jxgl,
filename=’D:\sql\jxgl.mdf’,
size=10MB,
maxsize=30MB,
filegrowth=5MB)
log on
(name=jxgl_log,
filename=’D:\sql\jxgl_log.ldf’,
size=4MB,
maxsize…
--创建数据库
create database jxgl
on
(name=jxgl,
filename='D:\sql\jxgl.mdf',
size=10MB,
maxsize=30MB,
filegrowth=5MB)
log on
(name=jxgl_log,
filename='D:\sql\jxgl_log.ldf',
size=4MB,
maxsize=10MB,
filegrowth=2MB)
--创建表
use jxgl
go
create table Student(sno char(12)primary key,
sname char(10),
ssex char(2),
sage tinyint,
snat char(8),
sdept nchar(20)
)
create table Course
(cno char(3)primary key, cname nchar(20), credit tinyint )
create table Sc
(sno char(12)references Student(sno),
cno char(3)references Course(cno),
primary key(sno,cno),
grade tinyint)
use jxgl
alter table Student
add constraint D_ssex default '男' for ssex --添加默认约束
alter table Student
add constraint age_check check (17<sage and sage<30) --添加检查约束
alter table Student
add constraint U_sname unique (sname) --添加唯一约束
alter table Sc
add constraint CK_grade check (0<grade and grade<100) --添加检查约束
alter table Student
alter column sdept nchar(25) null --修改列属性
alter table Course
add cdept char(20) null --新建列
alter table Course
drop column cdept --删除列
alter table Student
add spol varchar(20) null --增加新列
use jxgl
drop table Course --删除表
use jxgl
drop table Sc --删除表
use jxgl
drop table Student --删除表
文章来源: blog.csdn.net,作者:喜爱疯狂的徐大大,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/m0_46607044/article/details/116007487
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END