Home » Core Java » sql » SQL Create Table Example

About Simran Koul

Simran has graduated as a Bachelor of Engineering in Computer Science from Chitkara University. She has undergone a 6-months long comprehensive industrial training at the reputed Centre for Development of Advanced Computing (C-DAC), where she worked on a project including the likes of Java, JSP, Servlets while the UI-UX through the pioneering HTML, CSS and JS. Her inquisitive nature and the seed of curiosity keeps her on the toes to find material to write about. Along with her interests in Software Development, she is an ardent reader and always ready-to-write writer.

SQL Create Table Example

This article focuses on the functionality and usage of the SQL Create Table command.

A Relational Database Management System stores data in form of relations. A relation comprises of tuples and attributes. In layman terms, relation means a table comprising of rows and columns. A tuple is a row, whereas an attribute is a column.

1. Pre-requisites

You can implement the example of this article in two ways:

  1. By installing SQL in your local machine.
  2. On any online SQL compiler.

2. About Create Table Command in SQL

SQL Create Table command is used to create a new table in the database. You can also create a new table from a pre-existing table. Note that to create a table, you need to have an existing database.

3. SQL Create Table Syntax

Now, let us look at the syntax for the Create Table command.

CREATE TABLE tableName (
columnName1 datatype1,
columnName2 datatype2,
columnName3 datatype3);

4. SQL Create Table Example

  1. First of all, create a database. Let us create a database named example using the Create Database command.
Create Database example;

Then you have to use the database created above to create table.

Use example;
SQL Create Table - Create database
SQL Create database and use database

2. With that, you can now create a table using the Create table command. Let us say – we are creating a table named student data. The table has 3 columns. The columns are studentName , studentId, and studentAge where the first column is of type varchar, the others are integers.

CREATE TABLE studentData( studentName varchar(20), studentId number, studentAge number);
SQL Create Table -  Create table & describe
SQL Create table & describe table command

The describe command is used to check the structure of the table that you created using SQL Create table command.

5. Summary

This article also discusses the SQL Create Table command’s functionality and usage through the example. SQL Create Table command is one of the most fundamental commands in SQL. It also touches upon the relational database terminologies – relations, tuples, and attributes.

6. Download the source code

You should download the source code to implement the functionality of SQL Create Table command.

You can download the full source code of this example here: SQL Create Table Example

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments