From the course: Advanced SQL for Application Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Defining a partitioned table

Solution: Defining a partitioned table

From the course: Advanced SQL for Application Development

Start my 1-month free trial

Solution: Defining a partitioned table

(upbeat music) - [Instructor] Here is the solution to the challenge. So we're going to create a table called sales history and we're going to specify the attributes that I mentioned, product ID, product name, product type, total units sold, and month of sales. The key things here are that we have the primary key. And the primary key is defined using the month of sale and product ID, and we're creating a partition by range, so we specify month of sale. But that's all in the create table statement. And then, for each of the partitions we create a separate table and specificity it as a partition of sales history. Now here I'm just showing three months worth of data, but you can see the pattern. The full solution would include a total of 12 create table statements that are partitions of sales history, but this is an example solution using partitioning by range.

Contents