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

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

3 days ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

2 weeks ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

3 weeks ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

1 month ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

1 month ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

1 month ago