How to generate test data for all the tables in oracle
I am planning to use plsql to generate the test data in all the tables in schema, schema name is given as input parameters, min records in master table, min records in child table. data should be consistent in the columns which are used for constraints i.e. using same column value..
planning to implement something like
execute sp_schema_data_gen (schemaname, minrecinmstrtbl, minrecsforchildtable);
schemaname = owner,
minrecinmstrtbl= minimum records to insert into each parent table,
minrecsforchildtable = minimum records to enter into each child table of a each master table;
all_tables where owner= schemaname;
all_tab_columns and all_constrains - where owner =schemaname;
using dbms_random pkg.
is anyone have better idea to do this.. is this functionality already there in oracle db?
Ah, damorgan, data, test data, metadata and table-driven processes. Love the stuff!
There are two approaches you can take with this. I'll mention both and then ask which
one you think you would find most useful for your requirements.
One approach I would call the generic bottom-up approach which is the one I think you
are referring to.
This system is a generic test data generator. It isn't designed to generate data for any
particular existing table or application but is the general case solution.
Building on damorgan's advice define the basic hierarchy: table collection, tables, data; so start at the data level.
1. Identify/document the data types that you need to support. Start small (NUMBER, VARCHAR2, DATE) and add as you go along
2. For each data type identify the functionality and attributes that you need. For instance for VARCHAR2
a. min length - the minimum length to generate
b. max length - the maximum length
c. prefix - a prefix for the generated data; e.g. for an address field you might want a 'add1' prefix
d. suffix - a suffix for the generated data; see prefix
e. whether to generate NULLs
3. For NUMBER you will probably want at least precision and scale but might want minimum and maximum values or even min/max precision,
min/max scale.
4. store the attribute combinations in Oracle tables
5. build functionality for each data type that can create the range and type of data that you need. These functions should take parameters that can be used to control the attributes and the amount of data generated.
6. At the table level you will need business rules that control how the different columns of the table relate to each other. For example, for ADDRESS information your business rule might be that ADDRESS1, CITY, STATE, ZIP are required and ADDRESS2 is optional.
7. Add table-level processes, driven by the saved metadata, that can generate data at the record level by leveraging the data type functionality you have built previously.
8. Then add the metadata, business rules and functionality to control the TABLE-TO-TABLE relationships; that is, the data model. You need the same DETPNO values in the SCOTT.EMP table that exist in the SCOTT.DEPT table.
The second approach I have used more often. I would it call the top-down approach and I use
it when test data is needed for an existing system. The main use case here is to avoid
having to copy production data to QA, TEST or DEV environments.
QA people want to test with data that they are familiar with: names, companies, code values.
I've found they aren't often fond of random character strings for names of things.
The second approach I use for mature systems where there is already plenty of data to choose from.
It involves selecting subsets of data from each of the existing tables and saving that data in a
set of test tables. This data can then be used for regression testing and for automated unit testing of
existing functionality and functionality that is being developed.
QA can use data they are already familiar with and can test the application (GUI?) interface on that
data to see if they get the expected changes.
For each table to be tested (e.g. DEPT) I create two test system tables. A BEFORE table and an EXPECTED table.
1. DEPT_TEST_BEFORE
This table has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look BEFORE the
test for that test case is performed.
CREATE TABLE DEPT_TEST_BEFORE
TESTCASE NUMBER,
DEPTNO NUMBER(2),
DNAME VARCHAR2(14 BYTE),
LOC VARCHAR2(13 BYTE)
2. DEPT_TEST_EXPECTED
This table also has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look AFTER the
test for that test case is performed.
Each of these tables are a mirror image of the actual application table with one new column
added that contains a value representing the TESTCASE_NUMBER.
To create test case #3 identify or create the DEPT records you want to use for test case #3.
Insert these records into DEPT_TEST_BEFORE:
INSERT INTO DEPT_TEST_BEFORE
SELECT 3, D.* FROM DEPT D where DEPNO = 20
Insert records for test case #3 into DEPT_TEST_EXPECTED that show the rows as they should
look after test #3 is run. For example, if test #3 creates one new record add all the
records fro the BEFORE data set and add a new one for the new record.
When you want to run TESTCASE_ONE the process is basically (ignore for this illustration that
there is a foreign key betwee DEPT and EMP):
1. delete the records from SCOTT.DEPT that correspond to test case #3 DEPT records.
DELETE FROM DEPT
WHERE DEPTNO IN (SELECT DEPTNO FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3);
2. insert the test data set records for SCOTT.DEPT for test case #3.
INSERT INTO DEPT
SELECT DEPTNO, DNAME, LOC FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3;
3 perform the test.
4. compare the actual results with the expected results.
This is done by a function that compares the records in DEPT with the records
in DEPT_TEST_EXPECTED for test #3.
I usually store these results in yet another table or just report them out.
5. Report out the differences.
This second approach uses data the users (QA) are already familiar with, is scaleable and
is easy to add new data that meets business requirements.
It is also easy to automatically generate the necessary tables and test setup/breakdown
using a table-driven metadata approach. Adding a new test table is as easy as calling
a stored procedure; the procedure can generate the DDL or create the actual tables needed
for the BEFORE and AFTER snapshots.
The main disadvantage is that existing data will almost never cover the corner cases.
But you can add data for these. By corner cases I mean data that defines the limits
for a data type: a VARCHAR2(30) name field should have at least one test record that
has a name that is 30 characters long.
Which of these approaches makes the most sense for you?
Similar Messages
-
Recordcount for all the tables in my user
How I will get recordcount for all the tables in my user
with a single query??
Plz help.
Thanx in advance.Not possible. As there can be any number of tables with any names, this requires dynamic SQL.
SQL given to the Oracle SQL Engine cannot be dynamic ito scope and references - it must be static. For example, one cannot do this:
SELECT count(*) FROM :table
For the SQL Engine to parse the SQL, determine if it is valid, determine the scope and security, determine an execution plan, it needs to know the actual object names. Objects like tables and columns and functions cannot be variable.
You will therefore need to write a user function (in PL/SQL) that dynamically creates a [SELECT COUNT] SQL for a table, execute that SQL and return the row count - and then use SQL to iterate through USER_TABLES for example and sum the results of this function.
Note that object tables are not listed in USER_TABLES - thus a more comprehensive list of all table objects in your schema can be found in USER_OBJECTS. -
How to connect to database for all the reports FR
Hi,
I have developed 100 reports in production client, for testing purpose I have moved to
test client. How can I connect to database for all the reports at a time?
Regards
TaruniHi Taruni,
You can connect to the database connection for all the reports through workspace in HFM.
Connect to HFM Workspace-->click on Explore option-->and click on Tools-->click on Data Base Connection Manager and change the respective connections from Production Instance to Test Instance with required information, and than you will be able to connect to Test database for all the reports at a time.
Regards,
Srikanth -
In mdx how to get max date for all employees is it posible shall we use group by in mdx
in mdx how to get max date for all employees is it posible shall we use group by in mdx
example
empno ename date
1 hari 12-01-1982
1 hari 13-06-2000
by using above data i want to get max dataHi Hari3109,
According to your description, you want to get the max date for the employees, right?
In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
Regards,
Charlie Liao
TechNet Community Support -
Select data from all the table names in the view
Hi,
"I have some tables with names T_SRI_MMYYYY in my database.
I created a view ,Say "Summary_View" for all the table names
with "T_SRI_%".
Now i want to select data from all the tables in the view
Summary_View.
How can i do that ? Please throw some light on the same?
Thanks and Regards
Srinivas CheboluSrinivas,
There are a couple of things that I am unsure of here.
Firstly, does your view definition say something like ...
Select ...
From "T_SRI_%"
If so, it is not valid. Oracle won't allow this.
The second thing is that your naming convention for the
tables suggests to me that each table is the same except
that they store data for different time periods. This would be
a very bad design methodology. You should have a single
table with an extra column to state what period is referred to,
although you can partition it into segments for each period if
appropriate.
Apologies if i am misinterpreting your question, but perhaps
you could post your view definition and table definitions
here. -
Hi
I need to generate some test data and would like to know if there are any built functions in SQL Server 2012 that let you do that apart from using loops. In PostgreSQL I use different built in functions to achieve that for example the following statement
creates the test data for me, if any one can show me how I can do that using T-SQL
CREATE TABLE domain AS SELECT generate_series(1,100000) AS domain_id, substr('abcdefghijklmnopqrstuvwxyz',1, (random()*26)::integer) || '.com' AS domain_name;
And also I would like to know how do you get help on syntax in T-SQL, for example in PostgreSQL the following commands show you help etc so are there any similar commands in T-SQL ?
\h ALTER TABLE ( Will show you full syntax for ALTER TABLE )
\dt ( Will detail all the tables in the current Schema )
Thanks a lot
Rgds
TThe two T-SQL suggestions are great and probably the simple answer you're looking for. I wrote a blog article about using the VS data generation feature, as suggested by Chuck, to do some nice stuff here if you want to check that out:
http://blogs.msdn.com/b/samlester/archive/2012/08/04/creating-complex-test-databases-part-2-creating-a-database-with-1-billion-random-rows.aspx
Thanks,
Sam Lester (MSFT)
My Blog
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
"Mark as Answer" and
"Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread. -
How to add Test data for a function module
Hi experts,
i want to add test data for a function module . i don't know how to proceed on it . please help me...
with regards,
James...
Valuable answers will be rewarded...Hi,
- Go to SE37 and execute your FM
- Enter the data you want to pass to FM
- Hit 'Save' button. Enter the meaningful name for your test scenario and save. That's it you have saved the test data.
You can also enter some other test data and save that also. In short, you can save multiple test scenario. Also, you can give multiple test scenario a same name and they do not overwrite each other ( but normally you give different name to differentiate them)
Next time you come to execute the FM again, hit the "test data" button and it will show you all the test scenario you have stored before. Select the one you want to use and it will load the data in FM parameters.
Let me know if you need any other information.
Regards,
RS -
How to get test data for BAPI_PO_CREATE?
Hi friends,
can anybody please tell me how to generate the test data for BAPI_PO_CREATE?Hi swetha,
Hi,
You could test this scenario with using the Test Message option from RWB.
Or else
You could design the scenario to get the response from BAPI.
i.e BAPI to XI to File or any other application that will be easily avaialble.
But you need receiver system for testing.
Refer the below link it may help you .
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/66dadc6e-0a01-0010-9ea9-bb6d8ca48cc8
Regards
Naveen. -
How to write select query for all the user tables in database
Can any one tell me how to select the columns from all the user tables in a database
Here I had 3columns as input...
1.phone no
2.memberid
3.sub no.
I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
I am trying for this query since 30days...
Help me please....any kind of help is appreciated.....Hi,
user13113704 wrote:
... i need to include the symbol (') for the numbers(values) to get selected..
eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
Starting in Oracle 10, you can also use Q-notation:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
-- Run preliminary query to generate main query
SPOOL c:\my_sql_dir\all_ah_t.sql
SELECT 'select call time, record, agn from '
|| owner
|| '.'
|| table_name
|| ' where phone_no = ''6186759765'' and memberid = j34563298'
|| CASE
WHEN ROW_NUMBER () OVER ( ORDER BY owner DESC
, table_name DESC
) = 1
THEN ';'
ELSE ' UNION ALL'
END AS txt
FROM all_tables
WHERE SUBSTR (table_name, 1, 4) = 'AH_T'
ORDER BY owner
, table_name
SPOOL OFF
-- Restore SQL*Plus features that interfere with raw output (if desired)
SET FEEDBACK ON
SET PAGESIZE 50
-- Run main query:
@c:\my_sql_dir\all_ah_t.sql
so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"? -
[J2ME Polish] How to generate jad/jar for all devices?
Hello,
I've developed a J2ME Polish application using Netbeans 6.1 as IDE.
Now I'd like to generate the corresponding jad/jar for all the existing devices. How can I do that?
Furthermore, as soon as I'll have generated all these jar/jad, I'd like to put them all in a Web directory in order to make each device able to download the jad/jar corresponding to its configuration. How can I switch a given device towards the appropriate jad/jar in this Web directory?
Help me please, I'm really confused!
Thanks you in advance.
/arkienouEven though JDK1.4 is not officially shipping the
Java Plugin 1.4 documents on Security are fairly
good. Check out :
http://java.sun.com:80/j2se/1.4/docs/guide/plugin/developer_guide/contents.html
http://java.sun.com:80/j2se/1.4/docs/guide/plugin/developer_guide/rsa_how.html
regards,
atsSun
Sun Microsystems -
GL Account Master Data for all the inventory Accounts
Hi,
What is common & unique feature in the GL Master data of all the Inventory related accounts? Is it "POST AUTOMATICALLY" or some thing else
Thanks,
LavanyaIn addition to the 'post automatically' option, please also ensure the field status group selected is relating to 'material accounts'.
-
How to avoid report running for all the values in roll up of guided naviga
Hi
Thanks in Advance
I have 3 reports on three different pages of a dashboard. (Implemented guided navigation on one column of each report).When I click on value of guided navigation column it guides me to report 2 for that particular value (is prompted), same way for 3 report also till here it works fine.
However when I return from report 3 to report 2 and 2 to 1, the reports are running for all the values instead for the value which was passed by guided navigation of previous report earlier (Value on which I clicked to pass to the next report).
Edited by: 808623 on Nov 9, 2010 2:10 AMYes
Example : If i click on values 'X' in report 1
Report 2 shows results for 'X' only. And if i click on Value say 'Y' in 2 then report 3 shows for only 'Y'. But when i rollup from 3 to 2, Report 2 is showing for all values rather than showing 'x'.
I'm using Link or Image Dashboard Object > Destination>Request or Dashboard (path of previous report)
Edited by: 808623 on Nov 9, 2010 2:37 AM -
How to create a global property for all the reports in Oracle BIP
Hi,
I am a new guy to Oracle BIP. I have a set of reports which is running perfectly. But now, I have to create a property something like this:
If(bproperty)
else
I do not want to have a property for each of the reports but this should be a global one for all the reports.
Please help. Your help is greatly appreciated :)
Thanks,
KarthikHi,
I am a new guy to Oracle BIP. I have a set of reports which is running perfectly. But now, I have to create a property something like this:
If(bproperty)
else
I do not want to have a property for each of the reports but this should be a global one for all the reports.
Please help. Your help is greatly appreciated :)
Thanks,
Karthik -
How to write a procedure for update the table
Hi all
can any body please tell me how to write a procedure to update the table......
I have a table with about 10,000 records...........Now I have add a new column and I want to add values for that like
registration Code Creidits
13213 BBA
1232 MCS
I had add the creidit now i want to update the table.........the new value want to get by SQL like
Creidit = select creidit from othere_table...........
Hope u can understand my problem
Thanks in advance
Regards
Shayan
[email protected]Please try the following --
update Program_reg a
set TotalCreidit = ( select tot_cr <Accroding to your logic>
from Program_reg b
where a.Registration = b.Registration
and a.Enrollment = b.Enrollment
and a.code = b.code
where a.Registration in ( select distinct Registration
from Program_reg );
N.B.: Not Tested....
Regards.
Satyaki De. -
How to use the program "Generate test data for BAI bank statement" ?
Hi all,
I use the program RFEBKAT5 to create an Electronic Bank Statement file in BAI format ,but it doesn't generate the file .
I don't know how to generate the file.
Please help me !
Thanks all !You need to suitably adjust your GL accounts for "Posting Offset Account" (Whisch is defaulted as ++++++++19" and Checkout/Funds Out/Funds IN GL accounts to your configuration.
Once you do this try generating the file again.
Maybe you are looking for
-
I tried to play a song on my iphone 4 but it didnt let me so i thought let me update my iphone to the IOS 6.0.1 since i havent done it yet. When i did it told me to connect to itunes after doing so it told me i have to restore my iphone. But i cant s
-
Scope of Check Variation in Missing Part list Production Order
Hi, I have a problem that While creation or conversion from planned order to production order if i get missing part list i found that Scope of check is as Z6 and ZP (Checking rule).But when when i Release the same production order also am getting mis
-
Radius authentication for privileged access
Hello, I have configured Cisco 6513 for radius authentication with following commands. aaa new-model aaa authentication login authradius group radius line aaa accounting exec acctradius start-stop group radius radius-server host <radius-ip>
-
Third party software ipod back to pc! HELP
i lost all my music on my computer and installed third party software to copy music from ipod to put back into my liberay, but program copied music from i pod but didnt transfer it into liberay, is there a way? and not one by one? and also the music
-
Installing Oracle 10 G on Mac IBook G4
Hello, I am trying to set up Oracle on my Mac and am having some problems. I have the course materials and am eager to begin studying. My problem is that I am a novice and am having trouble using terminal/Darwin to install, create the enviroment, and