Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

SQL Reference

Rating
-
Sold
-
Pages
29
Uploaded on
20-08-2025
Written in
2021/2022

Provided best resource to learn about database and perform in many business scenarios to understand the trends

Institution
Course

Content preview

SQL
(Notes by Apna College)

What is Database?
Database is a collection of interrelated data.

What is DBMS?
DBMS (Database Management System) is software used to create, manage, and organize
databases.

What is RDBMS?
● RDBMS (Relational Database Management System) - is a DBMS based on the
concept of tables (also called relations).
● Data is organized into tables (also known as relations) with rows (records) and
columns (attributes).
● Eg - MySQL, PostgreSQL, Oracle etc.

What is SQL?
SQL is Structured Query Language - used to store, manipulate and retrieve data from
RDBMS.
(It is not a database, it is a language used to interact with database)

We use SQL for CRUD Operations :
● CREATE - To create databases, tables, insert tuples in tables etc
● READ - To read data present in the database.
● UPDATE - Modify already inserted data.
● DELETE - Delete database, table or specific data point/tuple/row or multiple rows.

*Note - SQL keywords are NOT case sensitive. Eg: select is the same as SELECT in SQL.

SQL v/s MySQL
SQL is a language used to perform CRUD operations in Relational DB, while MySQL is a
RDBMS that uses SQL.

,SQL Data Types
In SQL, data types define the kind of data that can be stored in a column or variable.

To See all data types of MYSQL, visit :
https://dev.mysql.com/doc/refman/8.0/en/data-types.html

Here are the frequently used SQL data types:


DATATYPE DESCRIPTION USAGE

CHAR string(0-255), can store characters of fixed length CHAR(50)

VARCHAR string(0-255), can store characters up to given length VARCHAR(50)

BLOB string(0-65535), can store binary large object BLOB(1000)

INT integer( -2,147,483,648 to 2,147,483,647 ) INT

TINYINT integer(-128 to 127) TINYINT

BIGINT integer( -9,223,372,036,854,775,808 to BIGINT
9,223,372,036,854,775,807 )

BIT can store x-bit values. x can range from 1 to 64 BIT(2)

FLOAT Decimal number - with precision to 23 digits FLOAT

DOUBLE Decimal number - with 24 to 53 digits DOUBLE

BOOLEAN Boolean values 0 or 1 BOOLEAN

DATE date in format of YYYY-MM-DD ranging from DATE
1000-01-01 to 9999-12-31

TIME HH:MM:SS TIME

YEAR year in 4 digits format ranging from 1901 to 2155 YEAR



*Note - CHAR is for fixed length & VARCHAR is for variable length strings. Generally,
VARCHAR is better as it only occupies necessary memory & works more efficiently.

We can also use UNSIGNED with datatypes when we only have positive values to add.
Eg - UNSIGNED INT




Types of SQL Commands:

, 1. DQL (Data Query Language) : Used to retrieve data from databases. (SELECT)

2. DDL (Data Definition Language) : Used to create, alter, and delete database objects
like tables, indexes, etc. (CREATE, DROP, ALTER, RENAME, TRUNCATE)

3. DML (Data Manipulation Language): Used to modify the database. (INSERT,
UPDATE, DELETE)

4. DCL (Data Control Language): Used to grant & revoke permissions. (GRANT,
REVOKE)

5. TCL (Transaction Control Language): Used to manage transactions. (COMMIT,
ROLLBACK, START TRANSACTIONS, SAVEPOINT)




1. Data Definition Language (DDL)

Data Definition Language (DDL) is a subset of SQL (Structured Query Language)
responsible for defining and managing the structure of databases and their objects.

DDL commands enable you to create, modify, and delete database objects like tables,
indexes, constraints, and more.

Key DDL Commands are:

● CREATE TABLE:

○ Used to create a new table in the database.
○ Specifies the table name, column names, data types, constraints, and more.
○ Example:
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50),
salary DECIMAL(10, 2));



● ALTER TABLE:

○ Used to modify the structure of an existing table.
○ You can add, modify, or drop columns, constraints, and more.
○ Example: ALTER TABLE employees ADD COLUMN email VARCHAR(100);

● DROP TABLE:

○ Used to delete an existing table along with its data and structure.
○ Example: DROP TABLE employees;

Written for

Institution
Course

Document information

Uploaded on
August 20, 2025
Number of pages
29
Written in
2021/2022
Type
Class notes
Professor(s)
K.gopi
Contains
All classes

Subjects

$8.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
kannekantisripathi98

Get to know the seller

Seller avatar
kannekantisripathi98 Tirumala Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
8 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions