Member-only story

SQL Removing Data And Table -Delete, Drop, Truncate Commands

The Test Lead
2 min readDec 2, 2022

--

This article will go over

  • Delete command
  • Truncate command
  • Drop command

Delete Command

The delete command allows you to remove 1 or more rows from a table

The command looks like below

DELETE FROM name_of_table WHERE some_condition

DELETE FROM name_of_table WHERE some_condition;

We would replace name_of_table with the table name we want to delete rows from. We would then replace some_condition with a condition to uniquely identify the rows(s) that we want to remove.

See this example below

DELETE FROM TestLeadSubs WHERE FirstName = ‘LeBron’

DELETE FROM TestLeadSubs WHERE FirstName = 'LeBron';

This would remove any row or rows from the table TestLeadSubs where the FirstName value is equal to LeBron

Truncate command

The truncate command lets you remove all of the rows inside of a table, but the table itself still exists.

The command looks like below

TRUNCATE TABLE name_of_table;

TRUNCATE TABLE…

--

--

The Test Lead
The Test Lead

Written by The Test Lead

Lead SDET at fintech company in NYC. Visit personal page http://thetestinglead.com// Twitter @juss_bailey Youtube @The Test Lead

No responses yet