Wednesday, September 14, 2011

How to Insert dummy data in a table to increase the size of the table in Sybase ASE?

Sometimes it is required to do performance testing of stored procedures and scripts over tables with large volume of data no matter of the exact data and the problem is we dont have data in the table. Then how to create dummy data in a table just to increase the size of the data. Well, one solution that we can use is to write insert statements in a while loop and insert same data again and again until we have sufficient data in the table or we can do something else? Yes, we can. How? Lets find it out..

To insert dummy data  into a table just to increase the size of the table in one shot can be done in the following way; however there is a high probability that u may end up filling up ur transaction log in this way if u choose very high input data in one shot. So, here is the example to show how we can do that -

First lets create a table from ASEISQL (a free Sybase editor available on the internet but you can use anything of your choice) like this -

create table TAB1
(
   EmpId int IDENTITY,
   EmpName varchar(100),
   EmpSalary float
)
go

Now open ISQL from cmd prompt as -

goto Run -> cmd.

In the command window type the following -

Isql -S<servername> -U<UserName> -P<password>

Now type the following in the isql prompt -

> use <database name>
> go
> insert into TAB1 (EmpName, EmpSalary) values('Tom', 10000.00)
> go 10000

As we can see the above statement will insert the above value 10000 times in the table TAB1 but this will be a logged event so take care as this will try to fill up your transaction log and you may end up yourself with a hung session. So, be careful!

No comments:

Post a Comment