zoukankan      html  css  js  c++  java
  • PowerDesigner批量生成日期型、中文字符型、数字型测试数据

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

    基本测试表如下:

    邀月工作室

    View Code
    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,可以如下操作:

    邀月工作室

    邀月工作室

     

  • 相关阅读:
    如何用互联网的思维开一家有逼格的客栈?
    create和grant配合使用,对Mysql进行创建用户和对用户授权
    Nginx 403 forbidden原因及故障模拟重现(转载)
    企业级缓存系统varnish应用
    实现基于Haproxy+Keepalived负载均衡高可用架构
    企业级监控zabbix基础
    实现基于Keepalived主从高可用集群网站架构
    实现基于LVS负载均衡集群的电商网站架构
    实现基于lnmp的电子商务网站
    CentOS6编译LAMP基于FPM模式的应用wordpress
  • 原文地址:https://www.cnblogs.com/downmoon/p/2400177.html
Copyright © 2011-2022 走看看