Member-only story

Top 25 SQL Questions for Interview

Rajan Sahu
12 min readMay 8, 2022

--

My article is for everyone! Non-members can click on this link and jump straight into the full text!!

This article will focus on a few key concepts and practicals that one may find useful for preparations for an SQL interview.

Introduction

This article will primarily focus on constructing SQL queries and understanding the concepts behind those queries.

1. How to write a SQL query to create a table.

create table employee_records(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(20),
Department varchar(20),
salary int,
PRIMARY KEY (Id)
);
  • The query above will create a table named employee_records with the following fields/columns:

Id: int

Name: varchar(20)

Department: varchar(20)

salary: int

  • Primary Key: Uniquely identifies a record/row in a table.
  • ID: The primary key of the table will be incremented automatically by the database management software (MySQL, Oracle, PostgreSQL, etc).
ALTER TABLE employee_records AUTO_INCREMENT=100;
  • ALTER TABLE can be used to set the starting value of the auto-incrementing id to…

--

--

Rajan Sahu
Rajan Sahu

Written by Rajan Sahu

Backend and Data Engineer by Day; Teacher, Friend and Content-Writer by night.

Responses (1)