11 SQL Basics for your Interview Prep
SQL – Structured Query Language, yes, you heard it right SQL is a language that we use to design and manage our Database. Let’s just take a second and learn about Database.
A Database is the collection of data that is nothing but information which is clearly organised so that we can easily access and modify the data. In general, databases consist of the information about employees in the office, students in college, sale transactions, and customer details, etc. We use SQL to access the database. Database Management System (DBMS) is software which we use to store, manage, and retrieve the data.
Stands for “Relational database management system”. RDBMS is the DBMS specifically designed for relational databases. It is a subset of DBMS. The relational database refers to a database in which the data is stored in a structured format with the help of rows and columns.
Relational database management system (RDBMS) is the fundamental of SQL and also for many modern database systems like MS SQL server, Oracle, MySQL, and Microsoft access.
In this article, we will see the basics of SQL which is easily understandable to beginners.
What is Structured Query Language:
Structured query language (SQL) is used to perform operations on the data (records) that are stored in a database. The operations may include updating, deleting, inserting, modifying, and creating tables, etc. SQL is a domain specific language that we use in programming to manage the data. We particularly use SQL to handle structured data. Which means the data that is organized in a tabular form.
There are two main advantages of SQL over the older read-write API’s VSAM and ISAM. Firstly, we can access many records with just a single command and secondly, in SQL there is no need to specify the index of the record we want to access.
Originally, SQL is based upon relational algebra and tuple relational calculus. SQL has many sub languages within it. They are:
- Data query language (DQL)
- Data definition language (DDL)
- Data control language (DCL)
- Data manipulation language (DML)
The scope SQL includes data manipulation (insertion, deletion, and updating), data query, and data definition (creation and modification).
SQL is the query language and it is not a database. To implement all these queries, we should have a database that supports these. For instance, we can use Oracle, MongoDB, MySQL, SQL Server, etc.
Why we need SQL:
We need SQL to create new databases, tables, and views. To insert the new data, to update the old records in a database, and to delete the records, and to retrieve the required data from the database.
Every language follows some set of guidelines and rules known as syntax. Now, let’s see a few basic syntaxes of SQL.
In general, we write SQL keywords in uppercase but SQL is not a case sensitive language. SQL statements depend on the text lines. We can use a single SQL statement in one or more text lines. We perform most of the action in the database with the help of SQL statements.
All the SQL statements start with any one of the SQL keywords like SELECT, INSERT, UPDATE, DELETE, DROP, ALTER, etc. And each SQL statement ends with a semicolon (;).
We use semicolons to separate one SQL statement from another. We need to separate one statement from another because in a database system, we write more than one statement in a single cell. So, we use semicolons to segregate these SQL statements. For example:
Let’s see a few important SQL commands we use frequently.
- SELECT – We use this command to extract the data from the database.
- UPDATE – We use this command to update the records in a database.
- DELETE – With the help of this command we delete the data in database.
- CREATE TABLE – This creates a new table
- ALTER TABLE – We use this command to modify the data in a table
- DROP TABLE – This command deletes the entire table
- CREATE DATABASE – It creates a new database
- ALTER DATABASE – This command helps to alter the database data.
- INSERT INTO – Using this we insert the data into the database.
- CREATE INDEX – We use this to create an index (key)
- DROP INDEX – This deletes the index
In this article, we just gave a brief about Standard query language and the importance of it in our daily lives.
Thanks for reading!