Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
70
Добавлен:
16.04.2013
Размер:
7.15 Mб
Скачать

Генерация sql сценария базы данных

  1. Для генерации SQL сценария базы данных перейдите к физической модели и в выберите командуDatabase\GenerateDatabase…:

укажите имя файла в который следует сохранить SQL сценарий и нажмитеOk.

В результате будет создан следующий сценарий:

/*==============================================================*/

/* DBMS name: ORACLE Version 8 */

/* Created on: 05.08.2004 12:39:11 */

/*==============================================================*/

alter table "Book"

drop constraint FK_BOOK_TOOKBOOK_PERSON;

alter table "Person"

drop constraint FK_PERSON_WORKSATLI_LIBRARY;

alter table "RegisteredInLibrary"

drop constraint FK_REGISTER_REGISTERE_LIBRARY;

alter table "RegisteredInLibrary"

drop constraint FK_REGISTER_REGISTERE_PERSON;

alter table "StoredInLibrary"

drop constraint FK_STOREDIN_STOREDINL_LIBRARY;

alter table "StoredInLibrary"

drop constraint FK_STOREDIN_STOREDINL_BOOK;

drop index "TookBook_FK";

drop index "WorksAtLibrary_FK";

drop index "RegisteredInLibrary2_FK";

drop index "RegisteredInLibrary_FK";

drop index "StoredInLibrary2_FK";

drop index "StoredInLibrary_FK";

drop table "Book" cascade constraints;

drop table "Library" cascade constraints;

drop table "Person" cascade constraints;

drop table "RegisteredInLibrary" cascade constraints;

drop table "StoredInLibrary" cascade constraints;

/*==============================================================*/

/* Table: "Book" */

/*==============================================================*/

create table "Book" (

ISBN VARCHAR2(30) not null,

"PassportNumber" VARCHAR2(20),

"Name" VARCHAR2(150),

"Author" VARCHAR2(70),

"Publisher" VARCHAR2(50),

"City" VARCHAR2(20),

"Year" NUMBER(4,0),

constraint PK_BOOK primary key (ISBN)

);

/*==============================================================*/

/* Index: "TookBook_FK" */

/*==============================================================*/

create index "TookBook_FK" on "Book" (

"PassportNumber" ASC

);

/*==============================================================*/

/* Table: "Library" */

/*==============================================================*/

create table "Library" (

"Number" INTEGER not null,

"Address" VARCHAR2(150),

"Phone" VARCHAR2(20),

constraint PK_LIBRARY primary key ("Number")

);

/*==============================================================*/

/* Table: "Person" */

/*==============================================================*/

create table "Person" (

"PassportNumber" VARCHAR2(20) not null,

"Number" INTEGER,

"FullName" VARCHAR2(70),

"Address" VARCHAR2(150),

"Phone" VARCHAR2(20),

"DateOfBirth" DATE,

"Photo" LONG RAW,

constraint PK_PERSON primary key ("PassportNumber")

);

/*==============================================================*/

/* Index: "WorksAtLibrary_FK" */

/*==============================================================*/

create index "WorksAtLibrary_FK" on "Person" (

"Number" ASC

);

/*==============================================================*/

/* Table: "RegisteredInLibrary" */

/*==============================================================*/

create table "RegisteredInLibrary" (

"Number" INTEGER not null,

"PassportNumber" VARCHAR2(20) not null,

constraint PK_REGISTEREDINLIBRARY primary key ("Number", "PassportNumber")

);

/*==============================================================*/

/* Index: "RegisteredInLibrary_FK" */

/*==============================================================*/

create index "RegisteredInLibrary_FK" on "RegisteredInLibrary" (

"Number" ASC

);

/*==============================================================*/

/* Index: "RegisteredInLibrary2_FK" */

/*==============================================================*/

create index "RegisteredInLibrary2_FK" on "RegisteredInLibrary" (

"PassportNumber" ASC

);

/*==============================================================*/

/* Table: "StoredInLibrary" */

/*==============================================================*/

create table "StoredInLibrary" (

"Number" INTEGER not null,

ISBN VARCHAR2(30) not null,

constraint PK_STOREDINLIBRARY primary key ("Number", ISBN)

);

/*==============================================================*/

/* Index: "StoredInLibrary_FK" */

/*==============================================================*/

create index "StoredInLibrary_FK" on "StoredInLibrary" (

"Number" ASC

);

/*==============================================================*/

/* Index: "StoredInLibrary2_FK" */

/*==============================================================*/

create index "StoredInLibrary2_FK" on "StoredInLibrary" (

ISBN ASC

);

alter table "Book"

add constraint FK_BOOK_TOOKBOOK_PERSON foreign key ("PassportNumber")

references "Person" ("PassportNumber");

alter table "Person"

add constraint FK_PERSON_WORKSATLI_LIBRARY foreign key ("Number")

references "Library" ("Number");

alter table "RegisteredInLibrary"

add constraint FK_REGISTER_REGISTERE_LIBRARY foreign key ("Number")

references "Library" ("Number");

alter table "RegisteredInLibrary"

add constraint FK_REGISTER_REGISTERE_PERSON foreign key ("PassportNumber")

references "Person" ("PassportNumber");

alter table "StoredInLibrary"

add constraint FK_STOREDIN_STOREDINL_LIBRARY foreign key ("Number")

references "Library" ("Number");

alter table "StoredInLibrary"

add constraint FK_STOREDIN_STOREDINL_BOOK foreign key (ISBN)

references "Book" (ISBN);

Соседние файлы в папке lab5
  • #
    16.04.20137.15 Mб70lab5.doc
  • #
    16.04.201345.78 Кб57library.cdb
  • #
    16.04.201340.05 Кб54library.cdm
  • #
    16.04.201364.11 Кб53library.pdb
  • #
    16.04.201385.79 Кб54library.pdm
  • #
    16.04.20136.29 Кб58library.sql