实验12.4 生成数据库

更新于 2026年10月10日 版权声明
实验12.4 生成数据库

【实验目的】

掌握使用Sybase PowerDesigner 16.5生成数据库的方法。

【实验内容】

从实验12.3建立的物理数据模型生成数据库。

【实验步骤】

①打开物理数据模型sales,在PowerDesigner界面的下拉菜单中,选择“Database”→“Generate Database”,弹出“Database Generation”对话框,如图12.30所示。

图示

图12.30 Database Generation对话框

②在选项页“General”中,选择SQL脚本保存的路径及输入SQL脚本的名称。在选项页“Options”中取消勾选“Drop Table”“Drop index”和“Drop procedure”,单击“确定”按钮,结果如图12.31所示。

图示

图12.31 Generated Files结果框

③查看步骤②保存的脚本文件sales.sql,内容为:

/*=============================================================*//* DBMS name:       MySQL 5.0                                    *//* Created on:      2022/7/7 16:19:29                            *//*=============================================================*//*=============================================================*//* Table: agents                                                *//*=============================================================*/create table agents(    aid                  char(3) not null,    aname                varchar(50),    city                 varchar(50),    percent              float,    primary key (aid));/*=============================================================*//* Table: customers                                             *//*=============================================================*/create table customers(    city                 varchar(50),    cid                  char(4) not null,    cname                varchar(30),    discnt               float,    primary key (cid));/*=============================================================*//* Index: citiesx                                               *//*=============================================================*/create index citiesx on customers(    city);/*=============================================================*//* Table: orders                                                *//*=============================================================*/create table orders(    ordno                char(4) not null,    pid                  char(3) not null,    cid                  char(4) not null,    aid                  char(3) not null,    month                varchar(12),    qty                  float,    dollars              float,    primary key (ordno));/*=============================================================*//* Table: products                                              *//*=============================================================*/create table products(    city                 varchar(50),    pid                  char(3) not null,    pname                varchar(50),    quantity             bigint,    price                float,    primary key (pid));alter table orders add constraint FK_ord_age foreign key (aid)    references agents (aid) on delete restrict on update restrict;alter table orders add constraint FK_ord_cus foreign key (cid)    references customers (cid) on delete restrict on update restrict;alter table orders add constraint FK_ord_pro foreign key (pid)    references products (pid) on delete restrict on update restrict;delimiter $$create procedure proc_Qcustomer (IN in_cid char(4),OUT out_cname varchar(30),OUT out_city varchar(50),OUT out_discnt float)beginSELECT cname, city, discnt into out_cname, out_city, out_discnt FROM customers WHERE cid = in_cid;end$$delimiter ;

↑上一章 ↓下一章
关注公众号获取验证码
复制内容需要验证码(7.99元/天)