Placeholder Image

字幕表 動画を再生する

  • creating these classes requires equipment and service.

  • Is that cost money?

  • If you appreciate this education, please think about going to Eli the computer guy dot com and offering a one time or monthly recurring donation.

  • Welcome back.

  • As you know, I am Eli the computer guy, and today I'm going to be teaching you how to in a certain records into tables and you're my sequel database.

  • And then how to be of a search through those records using something called This Select Command.

  • So basically what we're going to be doing is we're going to be inserting into a table that we create.

  • We're going to create a user's table.

  • We're going to basically insert a number of user records, and then we're going to be able to search through those user records using something called a select.

  • So that's what we're going to be showing you how to do today.

  • So this is pretty cool.

  • We're now to the point where we're getting to the meat and potatoes of my sequel, and you could actually do something useful with what I'm going to be showing you today.

  • If you really wanted to, it's there's not a lot of flash.

  • There's not a great user interface, but theoretically, if you wanted to create a database the way that I've showed you up until this point, created table for the database and then insert records into that table, you can then be able to sort through it using select.

  • And you have something that's kind of sort of useful, if maybe slightly ugly.

  • So this is kind of cool.

  • This is the point where we really start to do things that are pretty interesting.

  • So with that, let's go over to the computer so I can actually show you how to use, insert and select.

  • So here we are, back at my Mac book pro again.

  • I have a virtual box running, and I'm using the bun to desktop 18.4.

  • So the desktop is the gooey on a version of the U Bahn to operating system, and so we're going to be using that just again.

  • I think this is a good lab platform for when we start to do additional classes down the road when we start to use scripting.

  • Language is such as PHP in order to be able to connect with my sequel, so anyways.

  • With that, let's go down.

  • Click on the show applications, then go appear and you type in A terminals are going to the terminal and we click into terminal and yea, we have a terminal.

  • We'd have a nice little command prompt, but this isn't the right command prompt.

  • We need the my sequel Command prompt.

  • So we're gonna be using a pseudo my sequel.

  • So anybody coming to this series for the first time and going Wait a minute.

  • That's not how you're supposed to get into my sequel and you're kind of sort of correct.

  • We have not gotten into user accounts yet.

  • That will be in a class, maybe next class or the class after that.

  • Right now, we're just building out the internal structure of a my sequel database.

  • And then once that is done, I will show you how to create user accounts and deal with privileges, basically permissions and all that kind of stuff.

  • So right now we use pseudo my sequel to a log in to this my sequel database.

  • This will log us in as the A local host route user s O.

  • That we get full privileges.

  • If you have a normal database server already up and running and that already has user accounts with privileges.

  • This is the point where you'd simply typing my sequel space hyphen.

  • You space your user account space hyphen P, enter your password, and then you would have logged normally.

  • So yes, To be clear, this is a non standard way of logging, and that's what you get out of me.

  • Sometimes you get a non standard A cz we go.

  • 123456 and we hit Enter.

  • And now we're into the my sequel Command Proper Hit Control L.

  • A.

  • To clear the screen because I like a nice clear screen when I'm doing these instruction classes from here.

  • What I want to do is, I want to show that a basis, because again, whatever you come into my sequel database server, you want to get an idea of what's going on with the environment.

  • So what we have here is these are the databases and currently we only have the default databases.

  • So I deleted the data base on the table that we created before I guess so I can recreate them again for this class just again to kind of cement to the idea of being to create these databases and create tables.

  • This is an important thing for you to be doing as as as a new as a new book or somebody trying to learn how to do things like his database administration.

  • Basically, typing in commands is a skill set unto itself.

  • So remembering to do things like Hit the Send Michael and remembering specific syntax, it's one of those things.

  • The more time you do it, the more reputation repetition you have, the better you will become.

  • Just because you book, learn and theoretically can pass a test doesn't mean when you're sitting down a computer and going to tippy tap type out things on that you're going to do it properly.

  • So I would highly recommend, especially right now, when these projects are so ridiculously easy, you should try to basically, every time you come in, start delete The database is already there.

  • Start with the new database, start with new tables.

  • Just keep typing this and get used to inserting commands, doing the commands that I'm showing you s so in the future when you actually do have to build something for production environment.

  • You're done.

  • You can just tippy tap away and you're not thinking about a semicolon.

  • You're not thinking about a single quotation mark.

  • You're so used to it already.

  • It's just easy.

  • So that's what we're going to do Here is we're going to then create Oh, that a base.

  • And we're going to recreate that class d D.

  • That has been deleted before.

  • On there we go.

  • So create database, whatever the name is, and then semi colon on that gives us class D.

  • B from this point we're going to do is we're going to use class Devi.

  • And so that is this is going to drop us into the class database database.

  • Make sure when we're creating tables were created in the right place.

  • We don't wanna be created it in the information scheme over somewhere else.

  • Don't be clear.

  • He's up here.

  • These air, these air default, these default databases don't mess with him.

  • Basically, think of them as the A read history for my sequel.

  • Don't mess with them unless you know what the hell you're doing now Again to make sure that you always know what database your end before you start creating a table.

  • We can use the command to select that base, open parentheses, close parentheses, and then we do the semi colon, and this will show us what database we're currently in.

  • So we just want to verify We wanna verify were actually in the class database before we start creating tables.

  • And so we are so this control at all to clear the screen again.

  • And the first thing that we have to do then is create a table, right?

  • So if we go show tables we're going to see is there are no tables in this particular database, obviously because it has just been created.

  • So we're going to create a table for the user's eso For this, we're going to create table users, and then we're going to open parentheses.

  • We're going to go down one.

  • We're going to user i d.

  • So again, we're going to need an I d.

  • Number for all of these tables again.

  • User account.

  • One part number one, part number two.

  • So on and so forth.

  • This is going to be an int and interred.

  • You're you're going to do auto increment.

  • So that's what this means is every time a new record is created, it will increment up by one.

  • This is the first record is one second record is to their record is 3456 and then we're going to call this the primary key.

  • Always need at least what primary key and any table that you're gonna have and the user i d or the I d is a good place to have it.

  • Then we're going to go down to the next not line.

  • We're gonna do a name that will be a text field.

  • Then we d'oh, calm again.

  • Then we go down the next line or going to age.

  • We're gonna make that it in't.

  • So when it is a whole number 1 2000 and two, a float is a decimal 20.10 dot 10 $10.20.

  • Whatever else.

  • Since this is an age, uh, we're going to use a whole number.

  • We're not gonna worry about the kids, all the five year olds out there.

  • I'm five and 1/2 years old.

  • No, you're not.

  • You're five.

  • So are the database is concerned you're five.

  • Deal with it, and then we're going to say gender.

  • We're going to make this a text Now for this blast One.

  • You do not put a comma because it is the last one.

  • Then you're going to close the parentheses and then you're going to the semi colon, and then, oh, you're gonna look through and again, this is the reason this is the reason why it's good to keep typing in these commands over and over and over and again just to verify You don't fat finger it, because again, the computer will do exactly what you say.

  • And if you screw anything off, you have to redo it.

  • You don't know.

  • You don't know how many reshoots I do on this thes these particular classes.

  • Anyways, let's hope this works.

  • Let's hit.

  • Enter ueo query.

  • Okay, is it was affected.

  • When you get that that needs that actually works, eh?

  • So from this point we're going to do is we're gonna use this.

  • Describe command D E S C.

  • And then we're gonna look at the user's table.

  • Mr.

  • Verify, you know what fields we have and they're how they're supposed to be.

  • That's where the field with the user.

  • I d.

  • We have a name, we have aged, and we have gender, User.

  • I d is an end.

  • It is a primary key.

  • And for over the extra thing, it is auto increments.

  • So we'll go up.

  • 1234567 Then we have name that is text again.

  • It is very important to remember with these data types, if you screw up and you make the debt name an integer or float or something and then you start trying to insert data, it's Oh, you're gonna be very, very, very frustrated.

  • So new verify.

  • Do verify that these are correct.

  • So name is text.

  • That's how it should be.

  • Ages an inch.

  • That's how it should be in again.

  • Int Editor is a a whole number, not a decimal point.

  • So 12 will work 12.5 will not work.

  • So again, be careful of that because when we start doing insert commands, if you insert the wrong type of data, you will get errors and then you'll get frustrated on.

  • Then finally we have gender and that is text.

  • So Okay, so we have created the user's table at all of the data types.

  • Seemed to be appropriate.

  • So now we can actually go and we can start trying to insert data so it'll do to control L.

  • Again.

  • We're back here at the clear screen.

  • And so what we're going to do is we're going to say inserts into users table.

  • So the end, sir, Command, this is We're only putting data in two on the table users again.

  • This is one thing to really realize with any kind of programming language.

  • Any time when you're trying to talk to computers is once you get used to the language, it becomes easier when you realize that drop means delete.

  • Then it's pretty easy to figure out how to delete a database.

  • Or how did you leave the table when he realized that create basically equals new for most computer stuff?

  • Then you realize how easy it is to create databases and tables.

  • So again, it's all it's all just words here.

  • Once you figure out the words, you will be okay, so we're gonna insert, then we're gonna open parentheses.

  • And so the first thing that we're going to say is what columns we want to insert information into.

  • So we're going to insert information into the name column into the Age column and into the gender column again.

  • Don't you figure that, Uh, so we're saying is insert into user's name column age column and gender column.

  • You'll notice there is no ah user i d.

  • Column here because that is that auto increment that is going to automatically happen for us, and I do not want to screw with it.

  • So again, unless you actually know what you're doing, don't mess with your auto increment column.

  • Just let it do what it's gonna do.

  • So we're just gonna be adding the name, age, gender.

  • Then we're going to save values.

  • So now the values that will be put into name, age and gender and here, uh, we're going to do a single a single quotation mark, not a double quotation mark.

  • And so we're gonna say, Bob, close single quotation mark comma to divide.

  • So that's gonna be the names.

  • The name is Bob.

  • They were gonna make Bob, let's say, nine years old, closing quotation mark again, comma again, and the gender we're going to call Bob a boy and then we're going to close parentheses and then we're going to do send Michael.

  • And so we're gonna look at all this.

  • So for the user's for the columns, you will notice there is no single quotation marks.

  • So you just put those in there.

  • But then, for values, for Bob for nine and for boy, there are single quotation marks now, actually, for this if you have a number so you haven't in't.

  • You don't actually have to put a single quotation mark in there.

  • You could simply put that in there as a number, but again to be kind of simple for you.

  • If if you don't use single quotation marks on text, you will fail out.

  • If you do, you single quotation marks and numbers you won't fail out eso again Try to make this all standard.

  • I will just show you the ropes.

  • I'll just show you this today.

  • But remember, with numbers you actually don't have to have those single quotation marks.

  • And so hopefully hopefully here.

  • Everything's right.

  • Enter and they're ago a query.

  • Okay, one row, effective now I'm going to do is I'm simply going to press the up arrow key s o all this pops up again, So I want to add a few records.

  • So they were going to say, Let's say, Sue, And then Sue is going to be 15 years old, and Sue is going to be a girl.

  • So this is an easy way to add multiple records pretty quickly.

  • Dinner.

  • Okay, Run.

  • What?

  • One were affected.

  • It is.

  • We're gonna go up here.

  • We're gonna add a boy.

  • Oh, I don't know.

  • That boy's gonna be 17 years old.

  • We're gonna name that boy Fred Ener.

  • That's been added on.

  • Then Finally, we had to.

  • We had two boys and two girls are two boys, one girls.

  • We're gonna have a girl.

  • We're gonna make her five years old and we're gonna make her pet.

  • We're going to add her.

  • There we go.

  • So we have now added four records to the user's data.

  • So to name, age and gender, we've had a bomb.

  • Nine boy, we've added to 15 girl friend, 17 boy Pat, five girl.

  • And so those were now at it.

  • So what we can do now is we could actually start selecting, basically being able to read the records that are in this particular table.

  • So with that, I'm gonna hit control.

  • L declared screen again.

  • Now we're going to do is we're actually going to start selecting.

  • So basically, select is the statement.

  • This is how we say we want information out of this particular table, right?

  • So I'm gonna select and we're gonna do.

  • Is this also that asterisk key?

  • So what the asterisk e says is all all and so for this particular this field right here.

  • This is what columns of data you want.

  • Do you want the age?

  • Do you want the name?

  • So sometimes you just want names, and so you could do select name.

  • So that would only show you the column for names.

  • Oregon Select name and age and gender.

  • That would only show you those three.

  • We do select all this will show us all columns.

  • Then w