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

SQL_1

xcvszx

Uploaded by

chabdulmanan8953
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

SQL_1

xcvszx

Uploaded by

chabdulmanan8953
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

SQL

Structural Query Language


SQL
• 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).
• E.g. - MySQL, 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.
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.
SQL
• 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:
DQL (Data Query Language) :
1.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)
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:
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;

You might also like