3 Easy Steps on How to Create a Table in SQL

How to Create a SQL Table

How to Create a SQL Table

The ability to create a SQL table properly is one of the most essential skills a computer engineer should have.

But, if not, or new to database management, then this will be a refresher tutorial for you on how to create a SQL table.

Lets Create your SQL Table


Before we begin, make sure your set up has a SQL server. This example uses a MySQL server along with MySQL Workbench to create a table.

Your first assignment is to set up a connection.

To perform this, open MySQL Workbench, and click on the + icon to add a connection.

It will open a new dialog box where you can control the properties of the new connection. Add a new Connection Name and click OK.

After clicking on the connection, it will take you to the editor where you can input queries to create and manipulate schemas.

Let us test this code for creating a table, let’s create a new schema.

CREATE schema mySchema;
USE mySchema

This creates an SQL schema that stores tables and their relationships.

Create an SQL Table

In SQL, a table can be created using the CREATE keyword. While creating the t able, you need to specify its column names, data types, and primary key column.

Below are the general syntax:

CREATE TABLE table_name(
column1 datatype
column2 datatype,
column3 datatype,
columnN datatype,
PRIMARY KEY( columnName )

See the example using the general systax

use mySchema;
CREATE TABLE employee(
empID int not null,
empName varchar(25) not null,
emailID varchar(25) not null,

The NOT NULL phrase here indicates that whenever a new employee is added, all field shall not be left empty.

Let’s Add Values in an SQL Table

To add values in to the table, follow the command and arguments below:

INSERT INTO employee
VALUES (1, ‘Oscar Oganiza’, ‘oscar@oganiza.com’);

Displaying SQL Table Values


In displaying SQL values, we will use the SELECT command.

SELECT * from employee;

The * is an operator which selects everything by default. This will allow all rows off the employee table to be selected and displayed.

Learn more about SQL

This is a beginner tutorial on how to create, connect, and select database on SQL. There are lot more databases you can develop with it.

You can play around with its features such as queries and subqueries.

Lastly, the effectiveness of your SQL program comes down to how well you program, build and structure your tables. Keep this site bookmarked until you know how to build SQL Tables.

How to Create a SQL Table

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts