TABLE: A Beginner’s Guide to Creating Tables in SQL

Learn SQL with Udemy

For an instructor lead, in-depth look at learning SQL click below.


Welcome to our blog post! This tutorial , meant to familiarize you with the creation of tables in SQL. If you’re new to SQL or need a refresher on how to create tables, then this is the right guide for you.

What are Tables in SQL?

In SQL, a table is a collection of related data entries and it consists of columns and rows. Tables are the core of every database and SQL provides us with a number of commands to create and manipulate these tables.

Creating a Table

Before we can start performing operations, we first must create a table. In SQL, the CREATE TABLE statement is used to create a table.

Here, the table_name specifies the name of the table that you want to create. Each column name in the table is followed by its datatype.

Example

Let’s take an example of creating a “Students” table, which has three columns, namely, StudentID, FirstName and LastName.

Populating a Table

Now that we’ve created a table, let’s populate it with some data. The INSERT INTO statement is used to insert new data into a table.

Example

Now let’s insert some data into our Students table. We’ll insert a single student with a StudentID of 1, a FirstName of ‘John’, and a LastName of ‘Doe’.

To insert multiple rows into the table, we use multiple INSERT INTO statements.

Hope that cleared up how to create and populate tables in SQL for you! In upcoming posts we’ll delve more into manipulating these tables in SQL. Until then, happy coding!

Leave a Comment