Effective PyCharm Transcripts
Chapter: Databases
Lecture: Modifying the DB schema
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
You just have to modify data. What if we want to modify the structure of the table itself.
0:06
So we can come over here and actually work on these various things, we come over and say I'd like to modify the column and that will let us
0:12
actually work on the last updated column. But generally you want to work at I guess at least the table level.
0:19
So we'll come over here. It's a modified table and let's give it some room Here. You can see all of the columns that if I click on one I
0:28
could do things like remove it here and so on. You can see the keys, the indexes and the foreign keys there are known for
0:35
this table. We come over here and I could actually add one. I could say what we're gonna do is we're going to have a column called rating
0:42
that's going to be an integer and it's a default value is 3. How cool is that? Look at what is below though here is the actual SQL
0:53
DDL script that you need to run to make this change and I think that that is fantastic because these are the kinds of things I always forget.
1:02
What's the altar table thing for changing the column name. If there's data there. You know, things like that get really complicated.
1:10
Now I could push this button and it will happen directly or I could actually pull
1:14
this down and just stay open in the editor like so and I'm not really sure that I want to run this yet.
1:22
So here it is in the editor and I could decide or I could do some sort of transaction or I could match up a bunch of them so if we come
1:28
over here highlight that and we run it got some output here and notice we ran this and it completed. That looks pretty good.
1:38
You don't see it already did refresh. I was thinking it wouldn't refresh. There we go. Well here's our rating that we created so we could come over
1:45
and run this again and now we should have our rating in here somewhere. Perfect. You see now all of our entries have a rating and their default value
1:57
of three. Super cool. Huh? All right so let's go ahead and take that away again. We can come up we'll modify and then just hit the minus.
2:07
Gonna do a whole bunch of work to safely remove that and then put everything back like it was. But notice right there our rating is now gone again.
2:15
So if you need to modify the structure of one of these tables well there's a really cool way to do it.
2:20
Just go here do it in the editor and then hit save. Either generate a DDL.
2:25
Transformation script like we did the first time or just hit execute and make it happen right away.