Thus far, we’ve only worked with the actual data inside existing tables. But now we’re going to learn about adding new tables to our database. Later one we’ll get into the much more complicated steps of designing a good database. For today’s lesson, we’ll just keep it simple. You’ll learn how to get a new table added to your database using the CREATE SQL statement.
Before we go any further, we need to learn about a very powerful component of SQL server. The variable. If you have programmed in any programming language before, you already know what a variable is. If you haven’t, think of it as a sticky note that has space for you to write one thing. This sticky note has a predetermined lifespan, during which you can erase what it says and replace it with something else. You can ask to see what’s on the sticky note at any time, too.
Those of you who survived the subquery lesson are probably asking, “Isn’t there a simpler way to do all that?” The answer is, yes, there are simpler ways. We looked at the complex way first to help you understand how these things work. There are lots of alternatives to subqueries. We’ll take a look a brief look at each option for organizing or presenting a subset of data in today’s lesson and then discuss them in detail in the following lessons.
Now that we’ve learned how to insert and update data in SQL, we need to learn how to delete it. Deleting data is a little different than the other commands we’ve looked at. Deleting doesn’t deal with fields. It is strictly about rows of data. If you want to delete the contents of a single field, this is actually an update. Let’s jump right in with a look at the syntax for deleting a row or record in SQL.
Sometimes SQL code gets really complicated! We can’t always do everything we want in one neat statement. Before we delve into deleting data, we’re going to take a break and look at one of the trickier SQL concepts that we’ll use on a regular basis.
Now that we've learned how to add new information into our database, the next step is learning how to change what's already there. Updates in SQL server are not difficult. However, the power of the update statement is great, as we'll see in an example during this lesson. If you don't know what you're doing, you can cause some serious damage to your database!
We've now learned all about selecting data from a SQL server system. We've learned how to combine data results into meaningful aggregations, how to sort and filter data. However, a read-only database would be of very little benefit. The real power of SQL server comes from being able to insert, update and delete data from the system. Today, we’ll look at inserting data into SQL server.
This tutorial will explain the SQL Aggregates.
This tutorial will explain the advanced SQL Joins.
This tutorial will explain the basic SQL Joins.