Categories: DBMS

Introduction to SQL

A programming language called SQL (Structured Query Language) was created specifically for managing and modifying relational databases. It offers a common syntax for entering queries and making changes to data in databases. SQL was the first commercial language introduced for E.F Codd’s Relational model of a database.

Note:

  • The programming language SQL was created specifically for managing data kept in a relational database management system.
  • SQL is the language with which a coder communicates with a database to manipulate its data.
  • It is their guiding hand, voice, and fingertips dragging across a screen, helping the coder navigate and organize the data as they see fit.
  • It’s how a programmer communicates with the computer.
SQL Command:

There are numerous commands and statements in SQL that can be used to complete various tasks. The most typical SQL statements include the following:

DDL: Data Definition Language
  • DDL modifies the structure of the table by adding, removing, or changing tables, etc.
  • All DDL commands are automatically committed, which permanently saves all database changes.
CommandFunctioning
CreateUsed to create new tables, indexes, views, or other database objects.
DropUsed to delete tables, indexes, views, or other database objects.
AlterUsed to modify the structure of existing tables, indexes, or other database objects.
TruncateUsed to remove all data from a table.
DML: Data Manipulation Language
  • The database can be changed by using DML commands. It is in charge of making any kind of database changes.
  • DML commands cannot permanently save all database changes because they are not auto-committed. They are rollback able.
CommandFunctioning
InsertUsed to add new records to a table.
UpdateUsed to modify existing records in a table.
DeleteUsed to delete records from a table.
TCL: Transaction Control Language
  • Only DML commands like INSERT, DELETE, and UPDATE can be used with TCL commands.
  • These operations cannot be used when creating or deleting tables because they are automatically committed to the database.
CommandFunctioning
CommitUsed to save changes made to the database.
RollbackUsed to undo changes made to the database since the last COMMIT.
SavepointUsed to roll the transaction back to a certain point without rolling back the entire transaction.
DCL: Data Control Language

Any database user’s authority can be granted and revoked with the help of DCL commands.

CommandFunctioning
GrantUsed to give users or groups access to database objects.
RevokeUsed to revoke previously granted access to database objects.
DQL: Data Query Language

The data query language is used to retrieve data from tables based on simple conditions.

CommandFunctioning
SelectUsed to retrieve data from one or more tables in a database.

Note: also read about Fifth Normal Form (5NF)

Follow Me

Please follow me to read my latest post on programming and technology if you like my post.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

1 year ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

1 year ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

1 year ago

Binary Search Tree (BST)

A Binary Search Tree (BST) is a type of binary tree that satisfies the following…

1 year ago