0% found this document useful (0 votes)
15 views

2 Types-of-Commands-in-SQL- - skillcourse Advertising

The document outlines the five types of SQL commands: Data Definition Language (DDL), Data Manipulation Language (DML), Transaction Control Language (TCL), Data Control Language (DCL), and Data Query Language (DQL), each with specific commands and examples. It also compares SQL and NoSQL databases, highlighting differences in data storage, structure, schema, scalability, and use cases. The document emphasizes the importance of understanding these command types and their appropriate usage in database management.

Uploaded by

itmanarif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

2 Types-of-Commands-in-SQL- - skillcourse Advertising

The document outlines the five types of SQL commands: Data Definition Language (DDL), Data Manipulation Language (DML), Transaction Control Language (TCL), Data Control Language (DCL), and Data Query Language (DQL), each with specific commands and examples. It also compares SQL and NoSQL databases, highlighting differences in data storage, structure, schema, scalability, and use cases. The document emphasizes the importance of understanding these command types and their appropriate usage in database management.

Uploaded by

itmanarif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Day 2 : Command Types in

PostgreSQL

"30 Days, 30 Lessons: Unlock


the Power of SQL!"

Course created by Satish Dhawale | www.skillcourse.in


5 types Commands in SQL

COMMANDS

Data Data Transaction


Data Control Data Query
Definition Manipulation Control
Language Language
Language Language Language
DDL commands define, modify,
Data Definition Language (DDL) and manage database objects like
tables, schemas, and indexes.

Command Description Example


Creates a new database object CREATE TABLE employees (id INT,
CREATE
like a table. name TEXT);
Modifies the structure of existing ALTER TABLE employees ADD
ALTER
objects. COLUMN age INT;
Deletes database objects like
DROP DROP TABLE employees;
tables or views.
Removes all records from a table
TRUNCATE TRUNCATE TABLE employees;
quickly.
DML commands handle data
Data Manipulation Language (DML) within tables, such as inserting,
updating, or deleting rows.

Command Description Example

INSERT INTO employees (id,


INSERT Adds new records to a table.
name, age) VALUES (1, 'John', 30);

UPDATE employees SET age = 31


UPDATE Modifies existing data in a table.
WHERE id = 1;
Removes specific records from a DELETE FROM employees
DELETE
table. WHERE id = 1;

SELECT Retrieves data from the database. SELECT * FROM employees;


TCL commands manage
Transaction Control Language (TCL) database transactions, ensuring
data consistency and integrity.

Command Description Example


BEGIN Starts a transaction. BEGIN;
Saves all changes made in the
COMMIT COMMIT;
transaction.
Reverts changes made in the
ROLLBACK ROLLBACK;
transaction.
Sets a point within a transaction
SAVEPOINT SAVEPOINT sp1;
for rollback.
DCL commands control user
Data Control Language (DCL) access and permissions to the
database objects.

Command Description Example


GRANT SELECT,
Gives specific INSERT ON
GRANT
permissions to users. employees TO
user1;
Removes specific REVOKE INSERT ON
REVOKE permissions from employees FROM
users. user1;
• DQL focuses on querying data from the database.
Data Query Though technically part of DML, it’s often separated to
emphasize its importance
Language (DQL)

Command Description Example

SELECT Retrieves data from one or SELECT name, age FROM


more tables. employees WHERE age > 25;
• Pro Tip for Beginners
• Always use COMMIT and ROLLBACK carefully to avoid unintended changes,
especially in critical databases. Practice using SELECT frequently to understand your
data before making changes with DML commands.
Difference Between SQL and NoSQL Databases
Data Storage and Structure:

SQL: SQL Databases:


Banking systems, ERP SQL :
Data is stored in tables
with rows and columns systems, and applications PostgreSQL, MySQL,
(structured data). requiring complex queries Oracle, SQL Server.
and transactions.

NoSQL: NoSQL Databases:


Social media platforms, NoSQL
Data can be stored as key-
value pairs, JSON IoT data storage, real-time : MongoDB, Cassandra,
documents, wide-column analytics, and big data Redis, Couchbase.
stores, or graphs. applications.
Aspect SQL Databases NoSQL Databases

Data Model Relational (Table-based) Non-relational (Document, Key-Value, Graph, Column)

Structure Structured data stored in rows and columns. Unstructured or semi-structured data.

Schema Fixed schema (predefined structure). Flexible schema (dynamic structure).

Query Language Uses SQL for querying data. Uses various query methods (e.g., JSON-like queries).

Scalability Vertically scalable (add more resources to a server). Horizontally scalable (add more servers/nodes).

Strong ACID compliance (Atomicity, Consistency, Isolation,


ACID Compliance Eventual consistency (some NoSQL support ACID).
Durability).

Use Cases Suitable for complex queries and transactional data. Ideal for large-scale data, real-time analytics, and big data.

Examples PostgreSQL, MySQL, Oracle, SQL Server. MongoDB, Cassandra, Redis, Couchbase.

Performance Optimized for structured data and complex queries. Optimized for large volumes of data and fast reads/writes.

Relationships Supports relationships between tables (foreign keys). Stores data without predefined relationships.

Data Integrity Ensures high data integrity and consistency. Prioritizes scalability and speed over strict consistency.

Transactions Supports multi-row transactions. Limited or no support for multi-document transactions.

You might also like