加入后索引是否仍然存在?

时间:2016-06-15 04:08:50

标签: database indexing database-indexes

鉴于以下关系:

create table Students (
sid     integer,     -- 4 bytes
name    varchar(30), -- average length 20 bytes (incl padding)
bday    date,        -- 4 bytes
degree  char(4),     -- 4 bytes
primary key (id)
);

create table Courses (
cid     integer,     -- 4 bytes
code    char(8),     -- 8 bytes
term    char(4),     -- 4 bytes
title   varchar(40), -- average length 24 bytes (incl padding)
primary key (cid)
);

create table Enrolments (
course  integer,     -- 4 bytes
student integer,     -- 4 bytes
mark    integer,     -- 4 bytes
grade   char(2),     -- 4 bytes (with padding)
foreign key (course) references Courses(cid),
foreign key (student) references Students(sid)
);

主键cidsid每个都有一个两级B树索引。

如果我最初加入CoursesEnrolments,然后将此结果加入Students,那么最终表结果是否仍有{{1}上的两个索引}和cid

如果有人能够解释这个的机制,我会非常感激!

0 个答案:

没有答案