Reputation: 1796
I have some old project which has multiple databases with same structure. There is database for each language supported, so I have 4 databases with same structure. I think this is not efficient and it's hard to support and make updates to databases, so I want to create one database which will have new table Languages
with columns id
and code
and for each table add foreign key to this table. It should work well, but I also would like to partition every table to separate filegroup based on language.
So for example I have old table Customers
with structure (id, name, surname, data)
, so in new database it will have (id, name, surname, data, langId)
.
So I want to have something like customer_eng, customer_de, customer_it
filegroups based on langId.
Is it possible to do? I have found partitioning function and scheme, but there are only possibility to define some range values, but I don't need ranges, I want to group data to separate files based on langId, that's all what I want to do. If it's possible I would like to make it dynamic, so when new langId (new language added) is added it will automatically create new file for this language.
Upvotes: 0
Views: 148
Reputation: 1270773
You can define the separate partitions using ranges, by doing something like this:
CREATE PARTITION FUNCTION MyPartitionFunction (varchar(255))
AS RANGE LEFT FOR VALUES ('de', 'eng', 'it');
However, I would suggest using the actual ids instead:
CREATE PARTITION FUNCTION MyPartitionFunction (int)
AS RANGE LEFT FOR VALUES (1, 2, 3, 4, 5, 6);
Upvotes: 2