Hello, in this video we are going to look at altering the a table. So we've got this table here new users. And if you've already created the Auriga data, and then you might want to modify it slightly, so you can do a modification in code. So you create a query, and you compare it as you normally would in any other query. And now you just alter, then the table name. So here is a new user.
And we can say that they don't want to add a new column. And I like to put this on a separate line just purely for modifying stuff. I just like to visualize the as, okay, that's the table name, then you know, each row in the table, you know, each field should say, so we're gonna say add a new column. And first of all, you specify the names on say you Row, then the data types on integer. And yet we are good to go from, I believe we're good to go. We need to query execute.
So if I run that, there you go. You got new Rob, he says no, by default, that is fine. So what other modifications can we do, we can also drop a column. So I want to delete this column. Now, you know, the one that I just did there. I'll comment this out descent, because I'll provide all of this, you know, in on the GitHub link, so you can see what we did.
So far. basically want to get rid of this. You can just now say ALTER TABLE new use of drop column, and then the column name which was euro If I run that, reload, as you can see, it's gotten rid of just that column. Also bear in mind, if you get rid of the column, any data that was in that column is gone, that is gone. So make sure you be careful when you are dropping tables, columns, databases, you know, you want to be careful when you are doing that sort of stuff. What we can also do is basically modify a column as well.
So we could modify or change the datatype of a column. We. Yeah, so we can modify a column. So let's have a look at modifying the column to modify one. You just do modify Actually, no, I'm going to what I'm going to do is, yeah, that's fine. If I go here, I want to go to the structure.
We got this username that's a VAR char 32. Maybe I've changed my mind. And I think 32 is not long enough, and I want to support a 64. So we can do some modification. So we just do query equals nection. Prepare.
We do ALTER TABLE as we normally would. And then we say modified column. And then the column name, so one one and one for user name. And then if you are essentially resetting it, so the way you would, let's say, add a new row, and you say the column, you know, the field name, then you specify the data, maybe a potential limb for it. Potentially, you know this one with your last stuff, you just redo that and modify to the standard that you've set here. So as well char and say i said before i believe so if you don't structure and if he says say to reload it say no face at length of 64.
So that is how you modify an existing column so that if you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.