Skip to main content

SQL Table Partitioning

Link to the video -https://www.youtube.com/watch?v=tQQ3XwrKbfM&t=32s

SQL Table Partition is needed to improve the performance if you have large amount of data.


Creating Partition

-- Create a partition function
CREATE PARTITION FUNCTION salesDateRangePF (DATE)
AS RANGE LEFT FOR VALUES ('2022-01-01', '2023-01-01');

-- Create a partition scheme
CREATE PARTITION SCHEME salesDateRangePS
AS PARTITION salesDateRangePF
TO ([PRIMARY], [PRIMARY], [PRIMARY]);

-- Create a partitioned table
CREATE TABLE sales (
    sale_id INT,
    sale_date DATE,
    amount DECIMAL(10, 2),
    region VARCHAR(50)
) ON salesDateRangePS (sale_date);
Checking Existing Partition Functions
SELECT name AS PartitionFunctionName
FROM sys.partition_functions;

After Creating partition you will be able to see as shown below








Comments

Popular posts from this blog

Convex Lens Vs Concave Lens

What is a Lens A lens is a transparent object that transmits light across it, and its working principle depends on the   law of refraction (Snell’s law) . Applications: Concave Lens help with Far-Sight Convex Lens help with Near-Sight

Herbal Plants

Herbal plants to grow in home Different types of keerai ----- http://www.indiandietrecipes.com/2016/03/pictures-of-various-types-of-greens-or.html Pirandai ----good for bone joins---- https://youtu.be/k2DGubyXLAE Valarai Keerai Benifits ----- https://youtu.be/33HIfLJKTqA Sesma seeds ---- https://easyayurveda.com/2011/02/24/sesame-and-sesame-oil-benefits-total-ayurveda-details/

What is Verbal and Non-Verbal communication

TYPES OF COMMUNICATIONS: