Databases Reference
In-Depth Information
Figure 10-1. Process to create the first federation
In Step 1, you create a database using the regular CREATE DATABASE statement from the master database in SQL
Database:
// Create a 1GB database. This will become our root database shortly.
// Make sure you connect to master before running this statement.
CREATE DATABASE EnzoLog2
In Step 2, you create your first federation. Let's call this federation PurchaseHistory and pick a BigInt for
the partition key, which will be partitioned on purchaseId. Connect to your new database and run the CREATE
FEDERATION statement as follows:
// Connect to your new database before running this statement
CREATE FEDERATION PurchaseHistory (purchaseId BigInt RANGE)
Keep in mind that you will be charged for every new federation member you create, in addition to the
root database.
Note
The CREATE FEDERATION statement creates another database; it is your first federation member. Federation
members have random database names. The only way to connect to the federation is to issue the USE command. Now
that we have our first federation member, we need to build the schema (tables, stored procedures, and so on) of the
federation. This is important because the schema of this federation member will be used when we create additional
federation members.
If you are trying to federate an existing table, you will need to treat this operation as a data migration effort;
indeed you cannot simply federate a table that already exists in the root database. You would first need to create the
federation member, the table itself, and then use another tool (like SQL Server Integration Services) to migrate the
data from the root database to the federation member. At that point, you can start splitting the table located in
the federation member.
So let's connect to the first federation member and create a Purchase table. Notice that the USE FEDERATION
command requires a value for the federation key; it uses this value as a hint to find the correct federation member.
Because this is our first federation member, you can use any value for purchaseId; all possible values for purchaseId
currently point to the same federation member.
 
 
Search WWH ::




Custom Search