7 hours 36 minutes
I welcome back to Model three sequel programming. This is less than one sequel statements. And now we're on the final sub lesson of that lesson. 1.6 the delete statement. That's probably the statement that makes the most people nervous.
But let's go ahead and get started with it. So we're gonna go. We're going to again interact with the E p A employees position, Cavey extension table, the same table we used in the previous lesson
and to start off with I haven't empty. It's okay. If you still have a record in there, it won't make a difference. We're going to go ahead and use another neat feature of de Beber and generate some mock data for this table.
So if you right click on the data area,
you'll get an option to generate mock data. We're gonna go ahead and click on that
and you can I have the row counting the bass eyes set to 50. You consented to anything you like, though of course, the larger you said it, the longer it will take to complete. But I think 50 will be just fine for demonstrating the delete statement. So I'm gonna go ahead and click Start
and it is done. I'm gonna close this dialogue. I'm gonna click Refresh
And here we go. A bunch of mark data has been inserted into the table,
so let's go ahead and right Click the table and click
And again we will it
de Beber will show us the statement that will delete a record from the database. So let's go ahead and copy that
and let's see what our options are. We have a company.
Let's do 10 10 and our That's an easy one to remember, because we'll need to provide.
We don't have to provide all three keys, but typically when you're running into the lead statement an update statement, you want to be sure to, ah, use all the required keys. You don't have to. It just
it will help make sure that you don't accidentally ah, damage a relationship. If you view the diagram, we can see that those three are keys.
let's open a sequel. Editor New sequel editor.
Let's go ahead and haste in that command
again. It gave me the full name. I don't need the full name, so I'll just go ahead and get rid of that. It would work either way, though,
so we're record I d
or we'll start with company I d equals 10. We saw that was in there.
Field name was Let's go back and take a look.
Record idea and company I d was 10 field name was are all right?
So 10 10
So we're deleting from table where condition is true. So this the delete statements actually a little bit simpler. It's
condition. So delete from table where condition is true
Normally arranged this like this And when we run this we will get rid of this record.
So let's go ahead and run it.
We did something wrong.
We, uh, got an updated role of zero. We should have gotten a one.
Let's see what happened.
Record ideas. 10
Good ideas. 10.
Feel name is R
Ah, here's the problem. There's this face before that are
so it's not a match.
But if we do this,
we should get a match.
And we did
so when dealing with string of text, you do need to be
aware of such things that space is a value and it will cause
feels to not match if there's extra space where you don't expect it. So we got rid of that record,
and if we refresh, we will see it go away.
And sure enough, it went away.
Now let's say we wanted to clean out the table. How would we do that? Well, that's very easy. In fact,
we're going to say
delete from table
with no conditions
and we'll get a warning
because Dee Beavers knows this is clearing a table,
but we want to clear the table. So we're gonna go ahead and click, okay?
And we see that we
got rid of 49
records, which makes sense. We added 50. I deleted one. Before that left 49 on the table. We just deleted all of them.
Now we go back to the table and click. Refresh.
It's all gone now. Of course, if you were going to do that in a
production database, you would, of course want to be sure to back up that table first
and double check that that is the desired outcome. And, you know, sometimes it is in any case that finishes the delete statement. I hope you got your delete statement working. And, uh,
that finishes the lesson one of module three and I will see you in the next lesson. Thank you. Bye.
Penetration Testing and Ethical Hacking
The Penetration Testing and Ethical Hacking course prepares students for certifications, like CEH. This course ...
7 CEU/CPE Hours Available
Certificate of Completion Offered
This free course introduces the student to intermediate concepts found in the implementation and application ...
10 CEU/CPE Hours Available
Certificate of Completion Offered