当前位置:首页 » 操作系统 » powerdesigner生成数据库

powerdesigner生成数据库

发布时间: 2023-09-08 19:15:31

㈠ 如何利用powerdesigner自动生成一个具有外键的数据库

Powerdesigner对于一个刚开始接触的人,需要知道和了解的是操作,只有操作会了才会慢慢理解其中含义,而不是一来就讲发展背景,原理等等一大堆,后来也记不住,先把操作记清楚了,这些含义和原理会再不断的学习中显现出来,那时候再深究就会很深刻。
第一步:建立模型:
clip_image002
第二步,选择物理模型进行创建工作空间
clip_image004
第三:生成后的工作空间:
clip_image006
第四步,简单了解工具栏中的相关工具操作
clip_image008
第五步,实际建立一个空表
clip_image010
第六步:在表中放入表名
clip_image012
第七步:在表中放入相应的字段名,数据类型,字段长,主外键
clip_image014
最后按确定即可完成一个表。
第八步:继续建立一个表,步骤和之前一样
clip_image016
第九步:将两个表关联起来,通过工具中的关系进行自动生成外键
clip_image018
第十步:生成外键之后的物理模型图
clip_image020
第十一步:生成数据库
clip_image022
第十二步:生成数据库时的一些数据库文件名和路径的编辑
clip_image024
第十三:数据库文件生成完毕。
clip_image026
桌面上会出现这样一份文件:
clip_image028
将数据库文件右击txt打开时会看到sql语句:
/*==============================================================*/
/* DBMS name: Sybase SQL Anywhere 11 */
/* Created on: 2012/4/20 9:57:13 */
/*==============================================================*/
if exists(select 1 from sys.sysforeignkey where role=’FK_CLASS_REFERENCE_USER’) then
alter table class
delete foreign key FK_CLASS_REFERENCE_USER
end if;
if exists(
select 1 from sys.systable
where table_name=’class’
and table_type in (‘BASE’, ‘GBL TEMP’)
) then
drop table class
end if;
if exists(
select 1 from sys.systable
where table_name=’user’
and table_type in (‘BASE’, ‘GBL TEMP’)
) then
drop table "user"
end if;
/*==============================================================*/
/* Table: class */
/*==============================================================*/
create table class
(
class_id varchar(64) not null,
class_name varchar(64) null,
user_id varchar(64) null,
constraint PK_CLASS primary key clustered (class_id)
);
comment on column class.class_id is
‘班级ID’;
comment on column class.class_name is
‘班级名’;
comment on column class.user_id is
‘用户ID’;
/*==============================================================*/
/* Table: "user" */
/*==============================================================*/
create table "user"
(
user_id varchar(64) not null,
user_name varchar(64) null,
password varchar(64) null,
constraint PK_USER primary key clustered (user_id)
);
comment on column "user".user_id is
‘用户ID’;
comment on column "user".user_name is
‘用户名’;
comment on column "user".password is
‘密码’;
alter table class
add constraint FK_CLASS_REFERENCE_USER foreign key (user_id)
references "user" (user_id)
on update restrict
on delete restrict;
至此,如何利用powerdesigner自动生成,建立一个具有外键的数据库操作就完成了!
转载,仅供参考。

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:577
制作脚本网站 发布:2025-10-20 08:17:34 浏览:870
python中的init方法 发布:2025-10-20 08:17:33 浏览:566
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:749
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:668
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:992
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:239
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:97
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:790
python股票数据获取 发布:2025-10-20 07:39:44 浏览:696