Powerdesigner可以在数据模型中方便地生成测试数据

Powerdesigner可以在数据模型中方便地生成测试数据。本文主要简介利用PowerDesigner生成三种基本类型的数据:日期型、中文字符型、数字型。

基本测试表如下:

邀月工作室

  1. if exists (select 1  
  2.             from  sysobjects  
  3.            where  id = object_id('DepartDemo')  
  4.             and   type = 'U')  
  5.    drop table DepartDemo  
  6. go  
  7.   
  8. /*==============================================================*/  
  9. /* Table: DepartDemo                                            */  
  10. /*==============================================================*/  
  11. create table DepartDemo (  
  12.    PKID                 int                  identity(101,1),  
  13.    DName                nvarchar(200)        null,  
  14.    DCode                nvarchar(500)        null,  
  15.    Manager              nvarchar(50)         null,  
  16.    ParentID             int                  null default 0,  
  17.    AddUser              nvarchar(50)         null,  
  18.    AddTime              datetime             null,  
  19.    ModUser              nvarchar(50)         null,  
  20.    ModTime              datetime             null,  
  21.    CurState             smallint             not null default 0,  
  22.    Remark               nvarchar(500)        null,  
  23.    F1                   int                  not null default 0,  
  24.    F2                   nvarchar(300)        null,  
  25.    constraint PK_DEPARTDEMO primary key (PKID)  
  26. )  
  27. go  
  28.   
  29. declare @CurrentUser sysname  
  30. select @CurrentUser = user_name()  
  31. execute sp_addextendedproperty 'MS_Description',  
  32.    '部门表',  
  33.    'user', @CurrentUser, 'table''DepartDemo'  
  34. go  
  35.   
  36. declare @CurrentUser sysname  
  37. select @CurrentUser = user_name()  
  38. execute sp_addextendedproperty 'MS_Description',  
  39.    '主键ID',  
  40.    'user', @CurrentUser, 'table''DepartDemo''column''PKID'  
  41. go  
  42.   
  43. declare @CurrentUser sysname  
  44. select @CurrentUser = user_name()  
  45. execute sp_addextendedproperty 'MS_Description',  
  46.    '名称',  
  47.    'user', @CurrentUser, 'table''DepartDemo''column''DName'  
  48. go  
  49.   
  50. declare @CurrentUser sysname  
  51. select @CurrentUser = user_name()  
  52. execute sp_addextendedproperty 'MS_Description',  
  53.    '编码',  
  54.    'user', @CurrentUser, 'table''DepartDemo''column''DCode'  
  55. go  
  56.   
  57. declare @CurrentUser sysname  
  58. select @CurrentUser = user_name()  
  59. execute sp_addextendedproperty 'MS_Description',  
  60.    '主管',  
  61.    'user', @CurrentUser, 'table''DepartDemo''column''Manager'  
  62. go  
  63.   
  64. declare @CurrentUser sysname  
  65. select @CurrentUser = user_name()  
  66. execute sp_addextendedproperty 'MS_Description',  
  67.    '上级部门',  
  68.    'user', @CurrentUser, 'table''DepartDemo''column''ParentID'  
  69. go  
  70.   
  71. declare @CurrentUser sysname  
  72. select @CurrentUser = user_name()  
  73. execute sp_addextendedproperty 'MS_Description',  
  74.    '申请人',  
  75.    'user', @CurrentUser, 'table''DepartDemo''column''AddUser'  
  76. go  
  77.   
  78. declare @CurrentUser sysname  
  79. select @CurrentUser = user_name()  
  80. execute sp_addextendedproperty 'MS_Description',  
  81.    '申请时间',  
  82.    'user', @CurrentUser, 'table''DepartDemo''column''AddTime'  
  83. go  
  84.   
  85. declare @CurrentUser sysname  
  86. select @CurrentUser = user_name()  
  87. execute sp_addextendedproperty 'MS_Description',  
  88.    '修改人',  
  89.    'user', @CurrentUser, 'table''DepartDemo''column''ModUser'  
  90. go  
  91.   
  92. declare @CurrentUser sysname  
  93. select @CurrentUser = user_name()  
  94. execute sp_addextendedproperty 'MS_Description',  
  95.    '修改时间',  
  96.    'user', @CurrentUser, 'table''DepartDemo''column''ModTime'  
  97. go  
  98.   
  99. declare @CurrentUser sysname  
  100. select @CurrentUser = user_name()  
  101. execute sp_addextendedproperty 'MS_Description',  
  102.    '当前状态',  
  103.    'user', @CurrentUser, 'table''DepartDemo''column''CurState'  
  104. go  
  105.   
  106. declare @CurrentUser sysname  
  107. select @CurrentUser = user_name()  
  108. execute sp_addextendedproperty 'MS_Description',  
  109.    '备注',  
  110.    'user', @CurrentUser, 'table''DepartDemo''column''Remark'  
  111. go  
  112.   
  113. declare @CurrentUser sysname  
  114. select @CurrentUser = user_name()  
  115. execute sp_addextendedproperty 'MS_Description',  
  116.    '扩展1',  
  117.    'user', @CurrentUser, 'table''DepartDemo''column''F1'  
  118. go  
  119.   
  120. declare @CurrentUser sysname  
  121. select @CurrentUser = user_name()  
  122. execute sp_addextendedproperty 'MS_Description',  
  123.    '扩展2',  
  124.    'user', @CurrentUser, 'table''DepartDemo''column''F2'  
  125. go  


一、生成日期型测试数据

在“Column Property”中“Detail”,"Create"一个Test Data Profile如下:

邀月工作室

邀月工作室

邀月工作室

 

然后对相应的列选择该Profile,即可。

邀月工作室

邀月工作室

 

二、生成中文字符

思路如下:将需要生成的中文字符导入到一个文件或数据库中,然后从中随机生成。

首先,我们生成一个演示CVS文件,存放一组中文地区名称。

邀月工作室

类似地, 我们得先创建一个Profile,假定名称为Profile_CHSChar。

邀月工作室

修改属性如下:

邀月工作室

邀月工作室

然后,生成效果如下:

邀月工作室

 

三、生成数字型测试数据

邀月工作室

邀月工作室

邀月工作室

生成效果如下:

邀月工作室

 

最后,如果你需要导出或导入这些profile,可以如下操作:

邀月工作室

邀月工作室

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值