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

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

На основе созданной физической модели данных PowerDesigner может автоматически сгенерироватьSQL сценарий базы данных

  1. При генерации SQL сценария необходимо учитывать ограничения целевой СУБД, в частности в СУБДORACLE(8.1.6i) длина идентификаторов ограничена 30 символами.

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

Проверьте параметры генерации SQL сценария, укажите имя файла в который следует сохранить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 (

LIBNUMBER INTEGER not null,

ADDRESS VARCHAR2(150),

PHONE VARCHAR2(20),

constraint PK_LIBRARY primary key (LIBNUMBER)

);

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

/* Table: PERSON */

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

create table PERSON (

PASSPORTNUMBER VARCHAR2(20) not null,

LIBNUMBER 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 (

LIBNUMBER ASC

);

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

/* Table: REGISTEREDINLIBRARY */

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

create table REGISTEREDINLIBRARY (

LIBNUMBER INTEGER not null,

PASSPORTNUMBER VARCHAR2(20) not null,

constraint PK_REGISTEREDINLIBRARY primary key (LIBNUMBER, PASSPORTNUMBER)

);

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

/* Index: REGISTEREDINLIBRARY_FK */

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

create index REGISTEREDINLIBRARY_FK on REGISTEREDINLIBRARY (

LIBNUMBER ASC

);

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

/* Index: REGISTEREDINLIBRARY2_FK */

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

create index REGISTEREDINLIBRARY2_FK on REGISTEREDINLIBRARY (

PASSPORTNUMBER ASC

);

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

/* Table: STOREDINLIBRARY */

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

create table STOREDINLIBRARY (

LIBNUMBER INTEGER not null,

ISBN VARCHAR2(30) not null,

constraint PK_STOREDINLIBRARY primary key (LIBNUMBER, ISBN)

);

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

/* Index: STOREDINLIBRARY_FK */

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

create index STOREDINLIBRARY_FK on STOREDINLIBRARY (

LIBNUMBER 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 (LIBNUMBER)

references LIBRARY (LIBNUMBER);

alter table REGISTEREDINLIBRARY

add constraint FK_REGISTER_REGISTERE_LIBRARY foreign key (LIBNUMBER)

references LIBRARY (LIBNUMBER);

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 (LIBNUMBER)

references LIBRARY (LIBNUMBER);

alter table STOREDINLIBRARY

add constraint FK_STOREDIN_STOREDINL_BOOK foreign key (ISBN)

references BOOK (ISBN);

Соседние файлы в папке lab5
  • #
    16.04.20137.15 Mб107lab5.doc
  • #
    16.04.20137.15 Mб88lab51.doc
  • #
    16.04.201340.06 Кб78library.cdb
  • #
    16.04.201340.06 Кб77library.cdm
  • #
    16.04.201389.2 Кб74library.pdb
  • #
    16.04.201388.71 Кб78library.pdm