Contact
Site: US UK AU |

How to truncate MySQL tables

How to truncate MySQL tables

Overview
This article explains how to truncate MySQL tables with the phpMyAdmin control panel and with the MySQL CLI.

Definition

The truncate table operation functions as a quick way to remove all rows from a table while leaving the table itself intact. You cannot roll back this operation since truncate table bypasses DML to achieve faster performance.

Truncating tables with SiteWorx

You can perform the truncate table operation from SiteWorx with the following procedure:

  1. Log in to your SiteWorx account.

  2. On the left, select Hosting Features > MySQL > PhpMyAdmin (Figure 1).

Figure 1. Hosting Features > MySQL > PhpMyAdmin selection in SiteWorx.

  1. Select the correct database from the list on the left (Figure 2).

Figure 2. Database selection in phpMyAdmin.

  1. Select the check box corresponding to the desired table from the Table List (Figure 3).

Figure 3. Check boxes for table selection in phpMyAdmin.

  1. From the With selected list, click Empty (Figure 4).

Figure 4. With selected > Empty selection.

  1. Click Yes when prompted.

Truncating tables with MySQL CLI/SSH

Use the following procedure to perform the truncate table operation using the MySQL CLI:

  1. Log in to your hosting account using SSH:

mysql -u [username] -p [database_name)

For example:

mysql -u johndoe -p data_mysite

  1. Enter your password.

  2. Execute:

    truncate table [table_name]

External resources

For the complete MySQL documentation, refer to the MySQL website

For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to create a subdomain with SiteWorx
Added on Mon, Aug 5, 2013
How to repair MySQL tables
Added on Wed, Oct 28, 2015
How to restart your server
Added on Mon, Jan 26, 2015
What is MySQL Replication?
Added on Thu, Aug 28, 2014
How to create a pointer domain with SiteWorx
Added on Tue, Aug 6, 2013
How to secure your SiteWorx account
Added on Tue, Dec 9, 2014
How to import and export MySQL databases
Added on Fri, Nov 13, 2015
How to restore partial backups with SiteWorx
Added on Tue, Aug 6, 2013
How to reset your SSH password and add SSH keys in SiteWorx
Added on Wed, Feb 8, 2017
How to enable Let’s Encrypt
Added on Fri, Jul 27, 2018