DataFactory使用文档.doc_第1页
DataFactory使用文档.doc_第2页
DataFactory使用文档.doc_第3页
DataFactory使用文档.doc_第4页
DataFactory使用文档.doc_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

数据自动生成工具DataFactory使用文档版本 修订文档历史记录日期版本说明作者2012-12-231.0初稿张昌平用户指南Datafactory工具是Quest公司()旗下的产品,它能够根据用户定制,产生或导入需要的数据,插入相应的数据表或导出至外部文件。Quest DataFactory 是一种快速的、易于产生测试数据工具,它能建模复杂数据关系,且有带有GUI界面。DataFactory是一个功能强大的数据产生器,它允许开发人员和QA毫不费力地产生百万行有意义的测试数据。随机数据的例子包括随机数字,随机字符,并随机日期。有意义的数据包括名字,姓氏,城市,州和邮政编码。工作原理:DataFactory首先读取数据库中表的模式,即表的定义之类的内容,以列表的形式显示,如它的表和字段的数据库对象。然后由用户定制要产生数据的具体内容,如数字范围、字符串长度、要产生数据记录的个数等等,最后运行工程,生成数据。DataFactory支持的数据库类型有:DB2、SQL Server、Oracle,ODBC数据源以及Sybase。设置ODBC数据源的方法,即添加待操作的数据源(开始-控制面板-管理工具-ODBC数据源)。一、介绍1、Option选项:暂停数据产生。:停止数据产生。 :设置数据依赖的时间与当前时间的偏移。 :创建数据表。系统设置在View菜单下Option选项:2、DataFactory可以运行在命令行,在加载和运行的项目文件选项。在/ p标志可用于指定要加载的项目。在/ r标志可以用来显示该项目运行后,应加载它。一个可选的延迟可以指定与/ R参数表明,项目的实施应推迟n分钟。The following example runs DataFactory and loads a project:dfactory /p c:projectsnewproject.txfThe following example runs DataFactory, loads and runs a project:dfactory /p c:projectsnewproject.txf /rThe following example runs DataFactory, loads a project, sleeps for 10 hours, then runs the project:dfactory /p c:projectsnewproject.txf /r 600 Starting DataFactory from the Command LineDataFactory can be run from the command line with the option of loading and running project files. The following flag is provided: The /x flag can be used to indicate that the project should be run after it is loadedNote: You must be in the DataFactory directory to run from the command line. For example: C:Program FilesQuest SoftwareDataFactorybinExample Syntaxdfactory projectfile /xCommand Line ExamplesTo start DataFactory without loading a projectdfactory To start DataFactory and load a projectdfactory c:projectsnewproject.dfsTo start DataFactory, load, and run a projectdfactory c:projectsnewproject.dfs /xNote: If the path contains spaces, it must be enclosed in quotes. For example: dfactory c:my projectsnew project.dfs3、Age:老龄化数据数据老化搬迁日期字段的值前进和后退的过程。一个典型的老龄化数据的使用将是创建一个测试数据设置使用当前的日期,然后运行的有关数据和测试结果的捕获设置。然后,数据可以来岁的一个关键日期和测试可以重新运行是否符合规定。DataFactory提供了三种数据日期字段老化选择。l Do not age the field l Age the field using default options l Age the field using custom options二、数据库对象数据库属性对话框:数据库有下列属性NameUser IDAuto-Delete(工程运行前自动清除表中的原有数据)当这个选项被选中,先前在该项目中所包含的所有表生成的数据会被删除。这些表会按照数据库的引用完整性进行删除。Scan for dependencies and include related tables(自动包含与选中的表相关联的表)当创建一个项目,DataFactory可以选择扫描primary-key/foreign重要关系,包括相关的表,地图在项目表关系。用户至少包含一个表中的项目和DataFactory将包括所有直接或间接相关的包括表表。外键将被映射到主的相关表键。主键将自动设置产生独特的数值数据领域和独特的字符串字符字段序列。Available Tables Included TablesChanging Table Order 更改表的顺序表将被装载的顺序,他们在包括表列表中。如果您使用的临时数据表或运行SQL语句的执行时间,从一个表中插入到另一个产生的数据,那么重要的是,源表之前,目标表执行。要更改表的顺序,选择一个表,然后单击上移或下移按钮。Enclose Field Names 字段名称括一些数据库可以空白将在包括一个字段名称,例如:名字。此功能通常是由一名语法,允许字段名称被围封,例如:名字。如果数据库支持此功能,你希望有封闭式你可以打开此选项字段名称,并输入开始和结束字符。Enclose Table Names 附上表名有些数据库允许的空白将在包括一个表名,例如:订单细节。此功能通常是由一名语法,允许表名被围封,例如:订单明细。如果数据库支持此功能,你希望有封闭式你可以打开此选项表名称,并输入开始和结束字符。Execute SQL Script Before and After Project Execution指定SQL将之前和之后的表填充执行脚本。用户可以指定文件包含SQL脚本,并在运行时,该文件将被打开,该脚本执行。还有一个编辑按钮,将打开SQL脚本使用SQL文件关联的应用程序。此功能的一些可能的用途包括: 在数据插入之前,执行一个脚本用于删除或重新创建表。这可能是一个更有效的替代自动删除。 执行一个脚本删除限制,并在表上执行truncate。这可能是一个更有效的替代自动删除。 执行一个前脚本删除触发器和一个后脚本替换触发器。 执行一个前脚本删除索引和一个后脚本替换索引。 执行一个后脚本修改刚刚创建的数据。三、表对象表属性有Name RecordsNoteCreate temporary data table临时数据表可用于将一个表生成的数据回传到另一个表中。此选项的目的是为了方便一个表有多个外键,这些外键参照字段来自多个表。如果选择此选项,一个临时数据表将被创建,可用于向项目中的其他表插入数据。临时数据表与常规数据表一样,只是它们带前缀波形符字符(),而且他们被删除当应用程序退出时。Available FieldsIncluded FieldsField Order顺序See the section on the FIELD Token under Insert Value from SQL Database Table to understand how field order can be important.Output页面,设置导出行为:Child Table子表子表是一个依赖于其他表(父表)的表。子表和父表之间的关系可以是一对一,或一对多。要创建两个表之间的关系,右击父表对象,并从菜单中选择New Child Table。将显示子表对话框。子表的一般特性与正常表非常相似,但以下情况除外。Records:要插入的记录的数目可通过设置一系列低和高范围变量。要始终插入相同数量的记录,设置范围和低高度范围为相同的值。Relationship Properties:关系属性子表有一个附加的属性页,题为关系。这是您定义两个表之间的关系的地方。关系页面包含一个两列格。第一列表示子表的主键,第二个是父表的主键。要定义关系,在第一列中选择字段或多个字段。然后在父表中选择一个或多个字段中。例如:在图示描述的例子中,表df_customers和df_orders有一个一对多的关系,他们基于关键字段custid。当项目运行,对于每一个插入df_customers表中的记录,1至5条记录(与df_customers表中custid相匹配的记录)将被插入df_orders表中。这实际上模拟数据库中的每个客户customers将有1至5条订单orders。四、字段定义数据时,要考虑现有数据库表的约束,例如不可重复,不可为空等。数据表之间存在主外键关系时,应注意添加表的顺序并统一产生数据的方式,包含主键的表应先与外见表执行,否则将报错。数据设置面板分为两个部分,数据产生方式设置和数据格式设置。常用的数据产生方式有:Numeric: Numeric的数据产生方式有六种:它们分别是:l 从数据表插入数据,这里的数据表是系统提供的。l 从数据库插入数据,我们需要自己编写SQL语句从数据库中提取数据。l 用表达式产生数据,我们可以编写表达式,系统将使用结果生成数据。表达式中允许使用的运算符和格式请参见附录。l 插入连续的值,我们能够设定种子及增长值的大小,系统自动计算结果,如:种子为1,增长值为2,则产生的数据序列为1,3,5,7l 插入随机值,我们可以设置其范围,则结果大小在设定范围之内。l 插入常量,结果将为常量值Text:Text的数据产生方式也有六种它们分别是:l 从数据表中插入数据。l 从数据库中插入数据。l 从外部文件中插入数据。l 插入随机的字符组合,可以设置字符组合的长度。l 插入常量字符串l 插入组合文本,可以插入文本,数字,日期时间混合的文本。Date/Time: Date/Time的数据产生方式有五种它们分别是:l 从数据表中插入数据。l 从数据库中插入数据l 插入连续的时间,可以指定起始时间和增长时间。l 插入随机的时间,可以设置时间范围l 插入当前系统时间数据库中除上述三种数据类型外,还有许多其他的数据类型。When fields are included in a project, they will automatically be assigned a set of default properties based on data type. The default properties are as follows: Text fields will be filled with random characters Numeric fields will be filled with a random number between 0 and the maximum for the data type Data / Time fields will be filled with the current system date and time 一、 Text FieldsExtract a portion of the text选择此选项,插入一个子文本字符串。Case强制大写,小写,或混合的情况。Unique这个选项设置生成唯一值。KeySpecifies a collection of fields that, as a whole, must be unique, but do not have to be individually unique. Null Probability空概率决定这个字段生成空字段的概率。比如,值20将会导致大约20%的行的值为空。OptionThis is the method DataFactory will use to generate the field value. The available options are as follows: Insert text from a data table Insert text from a SQL database table Insert text from a file Insert random characters Insert a string constant Build a composite field 1、Inserting Values From a Data Table DataFactory comes with several data tables that contain First Names, Last Names, Cities, States and other useful kinds of data. Select this option to insert a value from one of these tables. See DataFactory Data Tables to learn how to create your own data tables.The following properties are associated with the Data Table option: Data Table The data table from which the value will be selected. Field The field in the data table from which the value will be selected. Option There are three options associated with fields that obtain values from DataFactory Data Tables. The options are: Select a record at random - this will randomly select a record from the Data Table Select records sequentially - this will select records in the order that they occur in the data table Synchronize with other fields from the same table - this will use the same record that was used for the first field in the table (in the order that the fields occur in the project) that uses the same Data Table与同一个表中的其他字段同步-这将使用相同的数据表的第一个记录字段 (以字段在项目中出现的顺序)2、Inserting Values From a SQL database table 此选项允许SQL语句指定将执行在运行时生成的字段值。 DataFactory可以在运行时插入SQL语句来执行某些操作。There are currently two tokens available, FIELD and RAND which can be abbreviated F and R. Tokens and their associated arguments are embedded in the SQL statement and enclosed with braces ( ). 目前有两种标记可用,FIELD and RAND,可以被缩写为F和R。标记及其相关参数被嵌入在SQL语句和括号()中。FIELD Token The FIELD token allows another field in the table to specified. The value that DataFactory generated for that field will be inserted into the SQL statement at run-time. FIELD标记允许其他的字段在表中被指定。 DataFactory为该字段生成的值将被在运行时插入到SQL语句。例如,假设您有一个Description字段和一个ID字段,并为Description字段指定以下的SQL语句:select ProductDescription from products where ProductID = F:ID If DataFactory generates the value 555 for the ID field, then the following SQL will be executed to generate the Description field: select ProductDescription from products where ProductID = 555 注意:为了使此选项正常工作,在标记中引用的字段必须在用SQL语句生成值之前生成。所以需要对表中的字段进行排序。RAND Token RAND标记被在运行时随机生成特定范围内的数值替换。Example select ProductDescription from products where ProductID = R:1:500 In this example the R:1:500 will be replaced with a number between 1 and 500 The random token can include an optional third argument that specifies how many decimal places the generated value will contain. If the parameter is omitted, the default is zero. For example: 随机标记可以包括一个可选的第三个参数,它指定生成的值包含多少个小数位。如果该参数被省略,默认值为0。例如:Expression Sample values r:.94:1.04 1, 0, 1, 0 r:.94:1.04:2 .95, 1.02, 1.01, .96 r:.94:1.04:4 3812, .9781, 1.2971, .9901 If more that one record is returned 如果一个以上的记录被返回有时,一个SQL语句将返回多条记录,即使只有一个值可以被DataFactory使用。此选项指定多个记录的返回应如何处理。目前有两种选择: Use the first record in the returned recordset Select a record at random from the set of returned records3、Insert text from a file Folder from which to select files For each record DataFactory will randomly select a file from this folder and insert the files contents into the field. Include subfolders Select this option to have files in subfolders included in pool of files from which the file will be randomly selected 4、Insert random characters Fixed number of characters Select this option to have a fixed number of characters inserted with each record.Random number of characters Select this option to have a random number of characters inserted with each record.5、Insert a string constant Constant ExpressionEnter the constant text expression that will be inserted with each record.6、Build a composite field 二、Numeric Fields Decimal Places 它指定产生多少小数点。Width 这将生成有特定数目的数字。例如,值9021,0005,0707都有四宽度。Unique Set this option on to generate unique values. Key Specifies a collection of fields that, as a whole, must be unique, but do not have to be individually unique. Auto Number自动编号有些数据库支持每一个被插入的记录自动编号,MS Access中这称为 - 自动编号,在MS SQL Server中这些被称为数字字段。自动编号属性是用来表明该字段的值是被数据库自动生成的,不应由DataFactory产生。插入记录后,这个字段的值会从数据库中被检索,以便它可以用来生成子表的外键值。Null Probability 空概率决定这个字段生成空字段的概率。比如,值20将会导致大约20%的行的值为空。Option This is the method DataFactory will use to generate the field value. The available options are Insert value from a data table Insert value from a SQL database table Sequential Values Random Values Constant Value Arithmetic Expression Arithmetic Expressions This allows a valid expression to be entered that will be evaluated at run time. This option supports the same tokens as the SQL option (F to include the value that was generated for another field and R to generate a random value). The syntax is the same as the SQL option but without the SQL keywords. The following operators and functions are supported: Oper Description Example *multiply f:salary * 2 / divide f:salary / 2 + add f:val + r:10:20 - subtract f:salary - 1000 power f:value 10 less than f:salary greater than f:salary 30000 sin sine sin(f:value) cos cosine cos(f:value) exp exponent exp(f:value) sqrt square root sqrt(f:value) log logarithm log(f:value) tg tangent tg(f:value) asin arcsine asin(f:value) acos arccosine acos(f:value) atg arctangent atg(f:value) 三、Date /Time Fields Option This is the method DataFactory will use to generate the field value. The available options are Insert value from a data table Insert value from a SQL database table Sequential Values Random Values Current System DateWeekdays and Weekend days 选择此选项,以产生工作日和周末日期Weekdays only Select this option to generate weekdays only Weekend days only 周末日期Select this option to generate weekend days only Unique Set this option on to generate unique values. Key Specifies a collection of fields that, as a whole, must be unique, but do not have to be individually unique. Null Probability Determines how often a null value will be generated for this field. For example, a value of 20 would result in a null value in approximately 20 percent of the rows. Format This is the format the date will have. This is provided for composite elements and for when you are writing the data to a flat fileSetting Standard FormatsThe standard format provides a variety of preformatted options. Below is a list of the available options with an example of each.Date:Time:blank: Field is blankblank: Field is blankShort date: 03/28/05Short time: 14:18:52Medium date: 28-Mar-05 Medium time: 02:18:52 PMLong date: Monday, March 28, 2005 Long time: 02:18:52 PM Central Standard TimeSetting Custom FormatsThe custom format settings allows you to generate the date/time fields using parameters. For example: Custom format: %m/%d/%Y %H:%M:%SGenerated date/time: 03/28/2005 14:18:52Below is a list of the available parameters.ParameterDefinition%aAbbreviated weekday name%AFull weekday name%bAbbreviated month name%BFull month name%cDate and time representing appropriate locale%dDay of month as decimal number (01-31)%HHour in 24-hour format (00-23)%IHour in 12 hour format (01-12)%jDay of year as decimal number (001-366)%mMonth as decimal number (01-12)%MMinute as decimal number (00-59)%pCurrent locales A.M./P.M indicator for 12 hour clock%SSecond as decimal number (00-59)%UWeek of year as decimal number, with Sunday as first day of the week (00-53)%wWeekday as decimal number (0-6; Sunday is 0)%WWeek of year as decimal number, with Monday as first day of the week (00-53)%xDate representation for current locale%XTime representation for current locale%yYear without century, as decimal (00-99)%YYear with century, as decimal number%z, %ZEither the time-zone name or the time zone abbreviation, depending on registry settings; no characters if time zone is unknown%Percent sign四、Blob FieldsThis option allows you to load a Binary Large Object (BLOB) when a script is executed.Use this Property.To.Insert a file from the following folderSelect a file from this folder and insert the files contents into the fieldInclude subfolders Have files in subfolders included in the pool of files from which the file is randomly selectedNull Probability Determine how often a null value is generated for this field. For example, a value of 20 would result in a null value in approximately 20 percent of the rows.Note: Null probability is grayed out if the field does not allow nulls.Folder from which to select files For each record DataFactory will randomly select a file from this folder and insert the files contents into the field. Include subfolders Select this option to have files in subfolders included in pool of files from which the file will be randomly selected Null Probability Determines how often a null value will be generated for this field. For example, a value of 20 would result in a null value in approximately 20 percent of the rows.To set BLOB properties1. Click the desired Field node. 2. Click . 3. Navigate to and select the desired BLOB file folder.4. Click OK.五、Drag-and-Drop Property Replication 该属性的复制功能,您可以复制一个字段的属性到一个或多个其他字段。这可以节省时间,如果你用大量的具有类似性质问题的字段。复制的字段的属性,只需将项目视图图标拖放到另一个字段。目标字段可以在任何项目视图(左窗格)或列表视图(右窗格中)。您可以在列表视图突出显示多个字段,再复制字段的属性到多个字段。五、数据表data tableDataFactory数据表是包含文本,数字和日期值的二进制索引文件。您可以轻松地从数据库或分隔的文本文件数据创建自己的数据表。要创建一个数据表,单击工具栏上创建数据表按钮,然后选择Import data from text file or Import data from database来导入数据。1、Import Data from Text FileThis option creates a data table from a specified text file. The text file must be formatted as follows: 每个记录以回车/换行终止 每个字段以一个逗号终止 表中的第一个记录包含字段名/数据类型对,用逗号分隔,字段名称和数据类型由冒号隔开 有效的数据类型为S =字符串,I=整数,R=实数,D=日期/时间 日期/时间值的格式采取mm/dd/yyyy hh:mm:ss,时间部分可选 Example: productid:i,price:r,description:s,orderdate:d 1,24.99,deluxe cheese slicer,2/25/1998 2,29.99,olive grinder,3/01/1998 3,34.99,carrot crusher,4/11/1998数据类型值默认为S字符串,没有必要指定的字符串字段的数据类型。2、Import Data from Database This option creates a data table based on a specified SQL statement 1. Click Connect to connect to a database 2. Enter the SQL statement 3. Click Create Data Table 教 程1、教程的概述To create the tutorial tables, select Help-Tutorial Setup from the main menu2、simple project本教程创建了一个数据库,跟踪客户订单的产品。在本教程中,Data Factory将扫描数据在数据库中的表并自动包括相关表。Step 1 - Creating a projectCreate a new project by clicking the New Project button on the toolbar. This will display the Project Properties dialog box. The project name defaults to New Project - change this to CustomerOrders.Click the Add button to add a database to the project. After selecting the type of database (Oracle, Sybase, ODBC, DB2 or MS-SQL Server) you will be presented with the appropriate dialogs to connect to the database. Once successfully connected, the database will be added to the project.Click OK to save the CustomerOrders project. This will present a File-Save dialog box, allowing you to name the file in which your project will be saved. The file name will default to CustomerOrders.txf.Select the folder in which you would like the project file saved and then click Save.The Database Properties dialog will now be displayed. In the Database Properties dialog box there are two list boxes labeled Available Tables and Included Tables.In the drop-down list above the Available Tables list, select the schema that contains the tutorial tables. This will display all the tables in that schema in the Available Tables list.Double-click on the DF_CUSTOMERS table in the Available Tables list to move it to the Included Tables list.Verify that the Scan for dependencies and include related tables option is turned on (this will scan and automatically include related

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论