How to Create Tables in SQL
&
5 Easy Ways for Beginners to Learn Databases
Data :
Data refers to any meaningful information that can be stored and reused.
Real- Life exemplifications :
->WhatsApp dispatches, images, vids = data
->Amazon Product rosters, reviews, orders = data
->Phonebook Names, figures = structured data
Database :
A database is an systematized system that stores data in a structured way for easy access, operation, and streamlining.
Think of it like a digital form press — everything is labeled and organized.
Database Management System (DBMS) :
A DBMS is software that helps you interact with the database. It allows
Storing data, Retrieving data, streamlining deleting data, Controlling access to data
-
- crucial Functions of DBMS Data Security
- Multi-user Access
- Provisory & Recovery
- Data Integrity
- Query Processing
Advantages of Using DBMS :
-> 🔐 Security part- grounded access control and encryption cover sensitive information.
-> ⚙️ Ease of Use Simplifies data entry, updates, and queries with intuitive interfaces.
-> 🕒 continuity & Vacuity Ensures data is safe from crashes and accessible 24/7.
-> ⚡ High Performance Fast queries and support for large datasets in real- time.
Types of Databases :
Relational Databases( RDB) :
Relational Databases( RDB) Data is stored in rows and columns( just like Excel).
Uses Structured Query Language( SQL) to manage data.
Ideal for structured, predictable data.
exemplifications:
-
- Banking systems( accounts, deals)
- E-commerce( products, orders, guests)
Popular Relational DBMS :
-
- Oracle
- MySQL
- PostgreSQL
- SQLite
- Microsoft SQL Garçon
- IBM DB2
Non-Relational Databases( NoSQL) :
Non-Relational Databases( NoSQL) Store data in formats like JSON, documents, crucial- value dyads, graphs.
Ideal for large- scale, unshaped orsemi-structured data.
exemplifications:
-
- Social Media platforms( stoner feeds, dispatches)
- IoT bias( detector data)
- Recommendation systems
Common NoSQL DBMS :
-
- MongoDB
- Cassandra
- Redis
- CouchDB
- DynamoDB
- Elasticsearch
Note : Choosing the Right Database script Recommended DB Type Banking, force, HR Relational DB Real- time converse apps, IoT, Analytics Non-relational DB Flexible schema needed Non-relational Structured business records Relational
Quick Comparison Relational vs Non-Relational point Relational DB Non-Relational DB Data Format Tables( rows & columns) crucial- value, JSON, etc. Schema Fixed schema Flexible schema Language SQL Varies( MongoDB, etc.) Stylish For Structured data unshaped/ Big Data Scalability Vertical Horizontal( distributed).An infographic showing six major types of databases — Relational, Analytical, Key-Value, Column Family, Graph, and Document — each designed to handle data in unique ways based on use case and structure.
How to Create Tables in SQL: Step-by-Step Guide
Databases and DBMS (Database Management Systems) allow us to house and organize vast amounts of data. Next we’re going to get into data and start working with data using SQL.
What is SQL?
SQL is an acronym for Structured Query Language. It is the language from which the meaning of Relational Databases is expressed.
Key Points About SQL:
- Create read update delete of data in any structure
- Works with relational databases such as: MySQL, PostgreSQL, SQLite and etc.
- It is also declarative, in that you tell the system what do to, and not how to do it.
- Extremely easy to learn, even beginners in poetry ads ideal candidate.
SQL Data Types :
common types of data used in SQL
Data Type | Syntax |
---|---|
Integer | INTEGER / INT |
Float | FLOAT |
String | VARCHAR |
Text | TEXT |
Date | DATE |
Time | TIME |
Datetime | DATETIME |
Boolean | BOOLEAN |
Notes:
- BOOLEAN is stored as a 1 for TRUE and 0 FALSE.
- DATE format: ‘YYYY-MM-DD’
- DATETIME format: ‘YYYY-MM-DD HH:MM:SS’
How to make Tables in SQL
We can achieve this by creating a new table in the database using the CREATE TABLE command.
Syntax:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
…
);
Replace table _name with your table name and select appropriate data type for each column.
How to Create Tables in SQL Example 1 : Create a Player Table
Lets Create a table to keep some of the details of the player.
CREATE TABLE player (
name VARCHAR(200),
age INT,
score INT
);
This table has 3 columns:
name: Player’s name
age: Player’s age
score: Player’s score
1.Test for yourself :
Student table example
Now we will make a table, student table to save school student’s records.
Column | Data Type |
---|---|
Name | VARCHAR(200) |
date_of_birth | DATE |
address | TEXT |
how to create tables in SQL:
CREATE TABLE student (
name VARCHAR(200),
date_of_birth DATE,
address TEXT
);
How to Create Tables in SQL Example 2 — Table Of Exam Schedule
Also, we will make an exam_schedule table as well.
Column Name | Data Type |
---|---|
name | VARCHAR(200) |
course | VARCHAR(200) |
exam_date_time | DATETIME |
duration_in_sec | INT |
pass_percentage | FLOAT |
how to create tables in SQL :
CREATE TABLE exam_schedule (
name VARCHAR(200),
course VARCHAR(200),
exam_date_time DATETIME,
duration_in_sec INT,
pass_percentage FLOAT
);
How to Know Table Structure – Using PRAGMA Command
If you need to see a table’s structure (columns and their types), you can use the PRAGMA TABLE_INFO command.
Syntax:
PRAGMA TABLE_INFO(
table_name
);
Example:
PRAGMA TABLE_INFO(employee);
Output Example:
cid | name | type | notnull | dflt_value | pk |
---|---|---|---|---|---|
0 | employee_id | INTEGER | 0 | 0 | |
1 | name | VARCHAR(200) | 0 | 0 | |
2 | salary | INTEGER | 0 | 0 |
cid = column ID
pk = primary key column
dflt_value = default value
Note:
If you mistype the table name, or it doesn’t exist, PRAGMA TABLE_INFO doesn’t return anything.
Summary :
- SQL works with data in a relational database.
- You can make tables with CREATE TABLE.
- Apply the appropriate data type that defines the type of data that each column can hold.
- this guide explains how to create tables in SQL using simple syntax and real exaples.
How to Create Table in SQL and Insert Rows in a SQL Table :
Working with databases means you’ll often need to add new information – like adding new players to a game or match details. In SQL That’s done using INSERT command.
Basic Syntax :
Here’s what a typical statement looks like :
INSERT INTO table_name (column1,column2,column3)
values
(value1,value2,value3),
(value4,value5,value6);
You can insert one row or even multiple rows at once. Just make sure the values match the columns.
Example : Adding Players
Let’s say we have a tables called player that keeps track of each player’s name age, and score. You can insert new player data like this.
INSERT INTO player (name, age, score)
VALUES
(“Ramana”, 27, 50),
(“Ramu”,26, 43) ;
That’s it! Two players added. Want to check if it worked?
SELECT * FROM player;
This will show all players currently in the table.
How to Create Tables in SQL Example: Adding Match Details :
You can also insert data into another table – like match_details, which might store which teams played, where and the result.
INSERT INTO match_details (team_name, played_with, venue, date, is_won)
VALUES
(“CSK”, “RCB”, “2022-05-21”, TRUE),
(“SRH”,”MI”, “Hyderabad”, 2022-05-27, TRUE);
Just a quick note :
- Date are written as ‘YYYY-MM-DD’.
- TRUE and FALSE work for boolean values, or you can use 1 and 0.
Common Mistakes You Should Avoid (how to create tables in SQL):
Wrong number of values :
INSERT INTO player (name, age, score)
VALUES
(“Dhoni”, “44” ); Only 2 values instead of 3
Wrong table name :
INSERT INTO player_info (name, age, score)
VALUES
(“Dhoni”, “44” ); Table doesn’t exist.
FAQ :
What is the introduction of SQL?
What are the 5 types of SQL?
How to create tables in SQL ?
What is SQL and what is used for?
What is SQL query with example?
What are the 5 types of SQL with examples?
What is SQL full form?
What is DBMS in explain?
How to create a data table in MySQL?
How to set up a table?
Try it Your Self :
Try how to create tables in SQL ? and inserting these into your table..
Name | Age | Score |
---|---|---|
Venky | 30 | 43 |
Ramudu | 30 | 49 |
Dhoni | 44 | 63 |
Got any questions or thoughts? Feel free to comment below. I’ll check it out and reply!
Got any questions or thoughts? Feel free to comment below. I’ll check it out and reply!
[…] How to Create Tables in SQL- 5 Easy Ways for Beginners to Learn Databases […]