Reputation: 862
I am trying to update a database table and the table's name format is employee_yearName_monthName. because I want to keep each month's data on a separate table.
Now at the start of the month there is no table for that month. SO i should create the table. But the question is how to decide whether the table exists or not?
thanks in advance.
Upvotes: 1
Views: 109
Reputation: 20736
I want to keep each month's data on a separate table
This is seriously BAD design! If you have huge amounts of data (at least in the range of 50-100GB, around a hundred million rows), rather prefer Partitioning (-->Oracle, -->MySQL. If you don't have that much data, just don't worry, store the data in one table, with the proper columns, and set up proper indexes!
Why is this a bad design? Just think about these:
EDIT as OP disclosed more details Solutions
USER_TABLES
management table to query for table names: SELECT * FROM USER_TABLES WHERE TABLE_NAME LIKE 'employeeName%
for example.Upvotes: 2
Reputation: 6341
As mentioned by others, this is not a good design. However, if you want to stick with your design you could just use
CREATE TABLE IF NOT EXISTS tablename ( ... )
Upvotes: 2