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
From the course: Advanced SQL for Application Development
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Overview of partitioning7m 10s
-
(Locked)
Range partitioning5m 52s
-
List partitioning3m 7s
-
(Locked)
Hash partitioning4m 27s
-
(Locked)
Querying partitioned tables1m 3s
-
(Locked)
Using read-only replicas1m 41s
-
(Locked)
Challenge: Define a partitioned table37s
-
(Locked)
Solution: Defining a partitioned table54s
-
(Locked)
-
-
-