What is the best way to learn SQL for data analyst?

Fundamental SQL Statements

  1. Create: creating a basic table involves naming the table and defining its columns and each column’s data type.
    Syntax :
    CREATE TABLE “table_name”(
    “column 1” “data type for column 1” [column 1 constraint(s)],
    “column 2” “data type for column 2” [column 2 constraint(s)],
    “column n”
    [“table constraint(s)”]);

Example :
create table Engineer_table (
Cust_id int,
First_name varchar,
Last_name varchar,
age int,
email_id varchar);

Constraints define the type of data which will be entered into the table column.
Now I am defining the type of Constraints, so please look below for a better understanding of constraints:

  1. NOT NULL Constraint: Ensures that a column cannot have NULL value.
  2. DEFAULT Constraint: Provides a default value for a column when none is specified.
  3. UNIQUE Constraint: Ensures that all values in a column are different.
  4. CHECK Constraint: Makes sure that all values in a column satisfy certain criteria.
  5. Primary Key Constraint: Used to uniquely identify a row in the table.
  6. Foreign Key Constraint: used to ensure referential integrity of the data.


  • A primary key is used to uniquely identify each row in a table and consist of one or more columns on a table.
  • When multiple columns are used as a primary key, they are called a composite key.
  • A foreign key is a column( or columns) that references a column (most often the primary key) of another table.

2. INSERT: The INSERT INTO statement is used to add new records into a database table.

INSERT INTO “table_name” (“column1″,”column2”,…) VALUES(“value1″,”value2”,…);

Single row (without column names specified)
INSERT INTO customer_table
VALUES(1, ‘chandan’,’Kumar’,23,’chandan@devopsschool.com’);

Single row (with column name specified)
INSERT INTO customer_table(cust_id,first_name,last_name,age,email_id)
VALUES(2, ‘Ajay’,’Kumar’,24,’ajay@devopsschool.com’);

Multiple rows
INSERT INTO customer_table
VALUES (1,’ck’,’dk’,35,’az@xyz.com’),

Chandan Kumar
Follow Me: