Join Martin Guidry for an in-depth discussion in this video Creating a table using Managment Studio, part of SQL Server 2014 Essential Training.
- View Offline
- Exercise Files
- In this section, we're gonna talk about creating tables. And tables are very important in a database. Almost all of the data stored in a database is stored in tables. And the tables define the structure and format of the data. So here in SQL Server Management Studio, I'm gonna open up the LyndaDemo database. I'll right click on Tables, the top option is New, and I'll say Table. In the interface presented, I'm first asked to provide a column name.
So for this demo, we'll be creating a table that holds information about people, and we'll want to store things like first name and last name. So I'll call the column, firstName. And for the Data Type, I'm going to be putting text into this column obviously. The SQL language has many different ways to store text. One of the most common is the varchar, which roughly stands for variable length characters. And in this case, it defaulted to 50.
So this column would hold a maximum of 50 characters, which is plenty enough for a first name. And variable length means the database will only use the amount of space necessary to hold whatever data we give it. So if we only input 10 characters, it will only reserve space for 10 characters, with a maximum of 50. The varchar Data Type does not accept unicode characters, if we want to use unicode characters, then we'll need to go with the nvarchar, and that would accept unicode characters.
We also have a checkbox on the end on whether or not to allow nulls. In other words, whether or not to allow blank values. I'm going to clear that checkbox. Then in the next row, I'll type in another column name. This column will be used to hold the data for the last name. So I'll call it lastName. And I'll use the same Data Type, nvarchar(50). And again, not going to allow nulls. This interface doesn't really allow me to name the table, that happens when I close the dialog.
It says would I like to save it, and I'll say yes. And at that point, I am prompted for a name of the table. And I'll just call this table, People. And now if I open up my list of tables, right click and hit refresh, I'll see a new table called People. There's a handful of different ways to get data into that table. The easiest of which might be to right click and go to Edit Top 200 Rows. And in the interface that comes up I can just type in first names and last names.
And when I'm done with that, I'll close the dialog. And again I'll right click on the name of the table. And I'll choose Select Top 1000 Rows, and we'll see all of the data in that table returned to us, and it is exactly what we just typed in. So great, we have a table, and we were able to insert some data into it, and then we were able to retrieve that data.
- Comparing SQL Server editions
- Installing SQL Server 2014
- Creating a database
- Creating tables and relationships between tables
- Writing SQL statements
- Creating views
- Using stored procedures and functions
- Working with XML
- Backing up and restoring a SQL Server database
- Monitoring SQL Server
- Authenticating users
- Importing and exporting data
- Indexing a database
Skill Level Intermediate
1. Overview of SQL Server 2014
2. Installing SQL Server 2014
4. Creating and Configuring Databases
5. Creating Tables in a Database
6. Working with SQL
7. Creating Views in Databases
Creating a view6m 1s
8. Understanding Programmability
9. Working with XML
10. Backup and Restore
11. Monitoring SQL Server
13. Importing and Exporting Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.