I need to pre populate SQLite database with random data (letters,numbers and @). How can i do this?
Asked
Active
Viewed 1,378 times
1
-
2How do you use SQLite? What programming language or shell? – Jun 13 '12 at 09:37
-
Manually insert data in the database using SQLite Browser & then follow this: http://stackoverflow.com/questions/9109438/using-already-created-database-with-android/9109728#9109728 – Yaqub Ahmad Jun 13 '12 at 10:34
2 Answers
1
You can do it using the INSERT
statement.

Oleh Prypin
- 33,184
- 10
- 89
- 99
-
1Potentially in combination with a `SELECT` statement to find out if it has already been populated. – Thilo Jun 13 '12 at 09:40
1
SQLite contains a random() function.
You can use it to generate the records you want to insert.
For example :
insert into sampleTable (colint, colchar) values (RANDOM(), CAST(RANDOM() AS TEXT))
In real cases, you should probably also combine it with min
and max
in order to produce values accorded to your need.

Denys Séguret
- 372,613
- 87
- 782
- 758