I have a function that returns me a random number, which this random number is actually the number of tables I need to generate late on.(e.g: if random number is:3 we will have tables called T1,T2,T3 or if random number is: 30 we will have T1,T2,...,T30 ).My problem is How can I do this?
1) how can I generate a table when I dont know the actual name of my table?
I dont know if even is this possible?
if it's not do you have any idea how can I generate my tables or any other way I can solve this problem?
But you do know the names of the tables you want to generate. You said:
if random number is:3 we will have tables called T1,T2,T3 or if random number is: 30 we will have T1,T2,...,T30
So do you have a problem generating a table whose name is T1? If so, what exactly is that problem?
posted 7 years ago
This should be possible. A couple of things to keep in mind, though -
1. You need to use a userid to connect to the DB that has appropriate permissions to run DDL commands
2. Introspect on the need to create tables. Can this be avoided?
You will have to generate strings with the names you want and run DDL commands using a prepared statement.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads