Introduction to SQL

  • March 12, 2023
  • DBMS
SQL Views

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:

DBMS SQL command
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

Leave a Reply

Your email address will not be published. Required fields are marked *