PowerDesigner 批量生成日期型、中文字符型、数字型测试数据

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

基本测试表如下:

邀月工作室

if exists (select 1
            from  sysobjects
           where  id = object_id('DepartDemo')
            and   type = 'U')
   drop table DepartDemo
go

/*==============================================================*/
/* Table: DepartDemo                                            */
/*==============================================================*/
create table DepartDemo (
   PKID                 int                  identity(101,1),
   DName                nvarchar(200)        null,
   DCode                nvarchar(500)        null,
   Manager              nvarchar(50)         null,
   ParentID             int                  null default 0,
   AddUser              nvarchar(50)         null,
   AddTime              datetime             null,
   ModUser              nvarchar(50)         null,
   ModTime              datetime             null,
   CurState             smallint             not null default 0,
   Remark               nvarchar(500)        null,
   F1                   int                  not null default 0,
   F2                   nvarchar(300)        null,
   constraint PK_DEPARTDEMO primary key (PKID)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '部门表',
   'user', @CurrentUser, 'table', 'DepartDemo'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '主键ID',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'PKID'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '名称',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'DName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '编码',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'DCode'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '主管',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'Manager'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '上级部门',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'ParentID'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '申请人',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'AddUser'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '申请时间',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'AddTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '修改人',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'ModUser'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '修改时间',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'ModTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '当前状态',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'CurState'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '备注',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'Remark'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '扩展1',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'F1'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '扩展2',
   'user', @CurrentUser, 'table', 'DepartDemo', 'column', 'F2'
go


一、生成日期型测试数据

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

邀月工作室

邀月工作室

邀月工作室

 

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

邀月工作室

邀月工作室

 

二、生成中文字符

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

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

邀月工作室

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

邀月工作室

修改属性如下:

邀月工作室

邀月工作室

然后,生成效果如下:

邀月工作室

 

三、生成数字型测试数据

邀月工作室

邀月工作室

邀月工作室

生成效果如下:

邀月工作室

 

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

邀月工作室

邀月工作室

 

 

 

邀月注:本文版权由邀月和CSDN共同所有,转载请注明出处。
助人等于自助! 
3w@live.cn  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值