Revisiting Basics of SQL
Before starting up on learning first let's learn what is SQL.
SQL, or Structured Query Language, is a programming language designed for managing and manipulating relational database management systems (RDBMS) and, in some cases, for manipulating and querying data in non-relational databases. SQL provides a standardized way to interact with databases, allowing users to define, manipulate, and query data.
- Table Structure:
— Data in a Relational Database Management System (RDBMS) is stored in tables.
— A table is a collection of related entries, organized in columns and rows.
- Fields in a Table:
— Fields are smaller entities within a table, corresponding to columns.
— Each field stores specific information about entries in the table.
- Records:
— A record is an individual entry in a table.
— Records are horizontal entities in a table, capturing detailed information about specific entities.
- Database Composition:
— A database typically contains one or more tables.
— Each table has a unique name, contributing to the organization and storage of data in the RDBMS.
Types of commands in SQL:
- DDL (Data Definition Language): SQL includes commands for defining and modifying the structure of database objects, such as tables, indexes, and constraints. Examples include
CREATE TABLE
,ALTER TABLE
, andDROP TABLE
. - DML (Data Manipulation Language): SQL includes commands for interacting with data stored in the database. This includes querying data, inserting new records, updating existing records, and deleting records. Examples include
SELECT
,INSERT
,UPDATE
, andDELETE
. - DCL (Data Control Language): SQL includes commands for controlling access to data in the database. This involves granting or revoking privileges to users. Examples include
GRANT
andREVOKE
. - TCL(Transaction Control Language): Transaction Control Language, is a subset of SQL (Structured Query Language) that deals with managing transactions within a database. The purpose of TCL commands is to control the transactions to ensure the integrity and consistency of the data within a database. Examples include
COMMIT
andROLLBACK
.