SQL: DELETE Statement

Instructor: Marcia Wert

Marcia has taught Information technology and Mathematics with a master's degree in IT

Explore how and what the SQL Delete statement does. The SQl Delete is only used in large, interconnected, relational databases where permanent removal is warranted. There is no trash can from which to recover records or files if it is implemented.

I am sure that you have seen the airport travel boards with their myriads of flashing lights that reflect incoming and outgoing flights, but have you ever envisioned what happens behind the scenes, where those flight times are recorded? And what happens when a flight is cancelled?

Fllight

SQL?

SQL, or Structured Query Language, is employed only in relational databases. SQL, which is pronounced SEQUEL, is a special programming language that is used to query, insert, update, or delete data in the form of records or tables. Think of query as asking a question to extract data from a table. Relational Databases are electronic tables that house enormous amounts of data. They are interconnected to each other by use of a primary key. Think of an airport in which you have connecting flights. The airport is actually the primary key where both planes will land and depart. It is what joins both flights. The airport in which you land could be considered a secondary key. The table would have the airport of the arriving terminal, but also house the name of the airport from which you departed on the flight.

Let's take our scenario where your flight has been cancelled. For the sake of convenience, only a portion of the table 'Flights' will be shown.

Flights (original):

Departing_Airport Arriving_Airport Flight_Number
OHR LAX 145
OHR LAX 699
LAX ATL 725

Flight 145 has been cancelled so you wish to delete that entry.

DELETE FROM table _name WHERE Flight_ Number = 'Corresponding Flight number';

or

DELETE FROM Flights WHERE Flight_Number = 145;

The corresponding table will now look like this--

Flights (after deleting Flight 145):

Departing_Airport Arriving_Airport Flight_Number
OHR LAX 699
LAX ATL 725

The Delete statement might also be paired with a query from another table. Let's say that we have two tables, one for Flights and one for Airports Names.

Flights:

Departing_Airport Arriving_Airport Flight_Number
OHR LAX 145
OHR LAX 699
LAX ATL 725
OHR ATL 525

Airport_Names:

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account
Support