From the course: Programming Foundations: Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating tables

Creating tables

From the course: Programming Foundations: Databases

Start my 1-month free trial

Creating tables

- [Instructor] Once I have a database I can work with I'll use the CREATE keyword in SQL along with parameters for our fields to tell the database what we want a table to look like. In SQL we'll start writing a description of how to create a table and we'll give it the name Customers. Then within a set of parentheses we'll add information about the columns. First, I'll add a field called CustomerID. That's our primary key for the table. For my notes I know that the data it will hold will be an integer, up to six digits. Because it's the primary key it can't contain a null value. That wouldn't make any sense. So it's not null and it'll auto-increment. Every time we add a new customer that new row will get a unique number, the next one in the sequence. There are different ways to indicate that a field is a primary key depending on the system you're using. In the system I'm using I need to add a line like this. Then…

Contents