Examples of TRUNCATE TABLE in MariaDB
To understand the TRUNCATE TABLE in MariaDB, we need a table on which we will perform the TRUNCATE TABLE command. So here we will create a table and insert some data into it.
Query for Create Table
CREATE TABLE Students
(
student_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
course VARCHAR(50),
);
Query for Insert Data:
INSERT INTO Students VALUES
(1, 'Ratnala', 'Harshavardha', 'CSE'),
(2, 'Maram', 'Harsha', 'Electrical'),
(3, 'Medishetty', 'Yashwanth', 'Chemical'),
(4, 'Sukumar', 'Reddy', 'Mechanical' ),
(5, 'Engula', 'Vamshi', 'Electronics');
We can check whether our data is inserted successfully or not using below command.
SELECT * FROM Students;
Output:
Explanation: Suppose we have a table named Students, and we want to remove all students records from the table while keeping its structure. We can done this using the TRUNCATE TABLE command.
Query:
TRUNCATE TABLE Students;
SELECT * FROM STUDENTS;
Output:
Explanation: The TRUNCATE query is executed successfully. As we can see that the records of “Students” table have been deleted permanently.
Truncate Table in MariaDB
MariaDB is an open-source relational database management system. It offers faster query execution and data manipulation as compared to other RDBMS. Also, it handles large datasets very efficiently. MariaDB Provides plugins for various functionalities like backup, performance monitoring, security, and data integration. MariaDB can easily integrate with other open-source software and cloud platforms.
In this article, We will learn about the Truncate Table in MariaDB along with its syntax, examples, and so on.