📄 crebas.sql
字号:
/*==============================================================*/
/* Database name: ConceptualDataModel_2 */
/* DBMS name: Microsoft SQL Server 7.x */
/* Created on: 2003-11-3 18:52:07 */
/*==============================================================*/
alter table Score
drop constraint FK_SCORE_TEST_STUDENT
go
alter table StuInfo
drop constraint FK_STUINFO_ENROLLMEN_STUDENT
go
alter table Student
drop constraint FK_STUDENT_ENROLLMEN_STUINFO
go
if exists (select 1
from sysindexes
where id = object_id('Score')
and name = 'Test_FK'
and indid > 0
and indid < 255)
drop index Score.Test_FK
go
if exists (select 1
from sysindexes
where id = object_id('StuInfo')
and name = 'Enrollment_FK'
and indid > 0
and indid < 255)
drop index StuInfo.Enrollment_FK
go
if exists (select 1
from sysindexes
where id = object_id('Student')
and name = 'Enrollment2_FK'
and indid > 0
and indid < 255)
drop index Student.Enrollment2_FK
go
if exists (select 1
from sysobjects
where id = object_id('Score')
and type = 'U')
drop table Score
go
if exists (select 1
from sysobjects
where id = object_id('StuInfo')
and type = 'U')
drop table StuInfo
go
if exists (select 1
from sysobjects
where id = object_id('Student')
and type = 'U')
drop table Student
go
/*==============================================================*/
/* Table: Score */
/*==============================================================*/
create table Score (
Stuno integer not null,
ID integer null,
major char(16) null,
score char(8) null,
constraint PK_SCORE primary key (Stuno)
)
go
/*==============================================================*/
/* Index: Test_FK */
/*==============================================================*/
create index Test_FK on Score (
ID
)
go
/*==============================================================*/
/* Table: StuInfo */
/*==============================================================*/
create table StuInfo (
stu_no integer not null,
ID integer null,
classname char(32) null,
depart char(64) null,
constraint PK_STUINFO primary key (stu_no)
)
go
/*==============================================================*/
/* Index: Enrollment_FK */
/*==============================================================*/
create index Enrollment_FK on StuInfo (
ID
)
go
/*==============================================================*/
/* Table: Student */
/*==============================================================*/
create table Student (
ID integer not null,
stu_no integer null,
Name char(16) null,
Sex char(8) null,
prov char(16) null,
birth datetime null,
constraint PK_STUDENT primary key (ID)
)
go
/*==============================================================*/
/* Index: Enrollment2_FK */
/*==============================================================*/
create index Enrollment2_FK on Student (
stu_no
)
go
alter table Score
add constraint FK_SCORE_TEST_STUDENT foreign key (ID)
references Student (ID)
go
alter table StuInfo
add constraint FK_STUINFO_ENROLLMEN_STUDENT foreign key (ID)
references Student (ID)
go
alter table Student
add constraint FK_STUDENT_ENROLLMEN_STUINFO foreign key (stu_no)
references StuInfo (stu_no)
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -