From the course: Hands-On Advanced SQL Server: Strategies and Techniques

GitHub Codespaces explainer video

- [Instructor] This course uses GitHub Codespaces, which is a ready-to-go coding environment called a workspace in the cloud. It allows you to write and run SQL from your browser without needing to install anything on your computer. The codespace for this course is preloaded with Microsoft SQL Server 2022 Standard Edition. In a little, I'll explain a little more about why we chose SQL Server for the course because it's not by error. For now, let's get familiar with how to access GitHub Codespaces and take a look around this environment when we do. Our first move in the overview area of the course, click on Open next to GitHub Codespaces in the Related to this course area. Once you do that, you'll be greeted with the sign in to GitHub page if you're not already signed in. If you don't have a GitHub account, click on the New to GitHub? link and create an account to open a free account. Once you do sign in, you'll see the following screen. Your next step at this point is to click on this big green Create codespaces on main button. Clicking on that button will begin the creation of your codespace. The first time around, this takes a few minutes to get spun up, so you have to be patient here. You'll see a screen like this while it's spinning up. You'll know when it's complete when you see this screen, which is what's referred to as the repository, sort of a default landing page whenever you first spin up this codespace. All right, so let's take a look around our environment here. I'll point out the main areas to pay attention to. So as I mentioned, this space is pre-configured with a specific relational database management system called Microsoft SQL Server. And the actual version we'll be using is 2022, which is not the latest version as of this recording, however, it is the most widely distributed. I'm deliberately working with SQL Server because there is a very high likelihood that the company you're working for or will work for has already invested in it. Okay, now let's walk through our environment here, just kind of keeping our eye on the main components. So starting with this black vertical bar here, we have a number of different icons displayed. Starting with the very first one up top, these three lines, this is like the menu item of the environment. So taking a look inside of this menu, we can see familiar items like File, Edit, Selection, View, and so forth. We'll be using this as we step through the course. Now, the next icon down from it is the explorer icon. And if you notice to the right here, there is an Explorer window here, this long rectangular area. And in it, we have a number of different files that belong to this particular space. Now, clicking on this icon just toggles this explorer bar open and closed. Now, as I mentioned, there's a number of different other items, but I'm going to skip down to the very last icon here called SQL Tools. Now clicking on that reveals this Connections area, and I'm going to just not expand any of these here, collapse them all, and go back to this, which is what you may see the first time that you navigate here to this Connections area. To the right of it, there is a little connect and disconnect symbol. So once you're disconnected, you do not see any symbol to the left of this local SQL server. But once I'm connected, you do see this little symbol that allows me to expand and go further into this server. Once I've expanded it, you can see that there's the MoviesDB database, which is the default database that we'll be working with throughout this course. And expanding further, going into the schemas, they're in dbo, I can see that there are now a tables folder and a views folder. Expanding that tables folder, I can see Actors, Directors, Genre, and so forth, all of the tables that are contained within my Movies database. Expanding the Actors, for instance, I can see the fields within this Actors table and as well as the data types for each field. Okay, so getting a good sense of this environment. And now, one more item I'd like to show you. Now to follow along with me and compose the queries we'll be introducing in the course, here's what you should do. Go back to this first item here. Go to File, then New Text File. That's going to pop up a new tab, Untitled-1, and you're going to see these items in front of you like this. I'm going to click on select a language and select SQL. And what that does is configures this area here to now be able to run my SQL queries. Up here you can see I have an item that says, "Run on active connection," and that allows me to run the queries I compose in the area here. So let's drop a quick SELECT * FROM, and I'm deliberately going to do an incomplete sequel statement and click on Run on active connection. This is going to attempt to run my statement and gives me this error as I don't have a table specified, but I wanted to show you this so that you can see where your errors would be displayed or your results. If you wanted to rerun this query, you simply click on RE-RUN QUERY, and that would rerun your query. Okay, now one other item is what if I wanted to save my work? So now if I go back to this item here, go to File, and I have a Save option here. I'm going to click on Save, and then I'm going to go down to the end here right before this SQL, and I'm going to rename this something more readable, like MyFirstQuery. And that is SQL, and I click on OK. Now that has now saved my work. Okay, that's it now for our walkthrough. One final item is what happens when you exit out of your GitHub codespace? So I'm going to do that as we often do, close that tab. When I go back and log into my GitHub repository, it's going to look something like this. It may look different in your instance, but what you're looking out for is this big green button here, which now says code in it. And if I expand it, I can see that I have my previously spun up GitHub codespace called refactored funicular. Now this is going to be a different name in your instance, it's a randomly generated name by GitHub, but it names your codespace. And when you want to go back into your codespace, you simply click on it, and that's going to spin up your GitHub codespace that you did previously. Now, the second time around, this is going to be much faster, and it's going to give you back all of the items that you would've created, including any files that you would've saved. And you can see, MyFirstQuery.sql, the file that I saved in my previous session, is still here, including the file that I was actually working with right in front of me here. Okay, that's it for now. Next up, we're going to dive a little deeper into how we're going to use the components of this environment and start creating our SQL queries.

Contents