MariaDB Create Index Statement Example
Let’s look at a real-life example. We’ll explore the MariaDB CREATE INDEX command. We’ll study different approaches and what they mean.
Lets create a table named sales that stores information about sales transactions. The table structure is look like this:
Query:
CREATE TABLE sales
(
transaction_id INT PRIMARY KEY,
product_name VARCHAR(50),
sale_date DATE,
quantity INT,
total_amount DECIMAL(10, 2)
);
Output:
Now, inserting some data into the table
Query:
INSERT INTO sales
(transaction_id, product_name, sale_date, quantity, total_amount)
VALUES
(1, 'Laptop', '2024-01-01', 100, 5000.00),
(2, 'Mobile', '2024-01-02', 50, 2500.00),
(3, 'Laptop', '2024-01-03', 75, 3750.00),
(4, 'Radio', '2024-01-04', 120, 6000.00),
(5, 'Mobile', '2024-01-05', 60, 3000.00);
Output:
Creating an index in MariaDB
MariaDB is an open–source and database management system. MariaDB is used for several purposes like as data warehousing, e-commerce, and logging applications. MariaDB is faster than MySQL in the replication and querying process. MariaDB supports invisible columns and temporary table space.
In this article, We will understand Creating an Index, the need for Indexing and creating various indexes for understanding, and so on.
It is useful to understand the MariaDB CREATE INDEX command. This boosts the speed of queries and makes databases work better, it increases query speed and improves database function.
Contact Us