Day 7: Diving into SQL – The Heart of Data & DevOps Foundations

AkankshaAkanksha
3 min read

Today I officially kicked off my journey with SQL (Structured Query Language) — the backbone of relational databases and a crucial skill in the DevOps and Cloud Engineering toolbox.

Whether you're spinning up Amazon RDS, building a backend pipeline, or setting up monitoring and alerting dashboards, SQL is the silent engine powering the structured data world.


What I Covered Today

What is SQL and Why Does It Matter?

SQL is the standard language used to create, manage, and manipulate relational databases. As a DevOps engineer, SQL helps you:

  • Interact with RDS or Aurora databases in AWS

  • Automate test data for CI/CD pipelines

  • Analyze logs, performance metrics, and audit trails

  • Write infrastructure-as-code that also provisions database layers


SQL Command Categories – Understanding the Core

To avoid writing SQL blindly, I studied how SQL is classified. Here's a quick overview of each category and what it's used for:

1. DDL – Data Definition Language

Used to define or modify database schema.

  • Commands: CREATE, ALTER, DROP, TRUNCATE

  • Example:

      CREATE TABLE devops_logs (
        id INT PRIMARY KEY,
        service_name VARCHAR(100),
        log_level VARCHAR(10),
        log_message TEXT
      );
    

2. DML – Data Manipulation Language

Used to insert, update, or delete data.

  • Commands: INSERT, UPDATE, DELETE

  • Example:

      INSERT INTO devops_logs VALUES (1, 'nginx', 'INFO', 'Server started successfully');
    

3. DQL – Data Query Language

Used to retrieve data.

  • Command: SELECT

  • Example:

      SELECT * FROM devops_logs WHERE log_level = 'ERROR';
    

4. DCL – Data Control Language

Used for setting permissions and access control.

  • Commands: GRANT, REVOKE

  • Example:

      GRANT SELECT ON devops_logs TO 'readonly_user';
    

5. TCL – Transaction Control Language

Used to manage changes made by DML statements.

  • Commands: COMMIT, ROLLBACK, SAVEPOINT

  • Example:

      BEGIN;
      UPDATE devops_logs SET log_level = 'DEBUG' WHERE id = 1;
      ROLLBACK;
    

Practice Snippets

Here are a few sample commands I wrote and tested locally:

-- Create table (DDL)
CREATE TABLE users (
  id INT PRIMARY KEY,
  username VARCHAR(50),
  role VARCHAR(20),
  created_at DATE
);

-- Insert data (DML)
INSERT INTO users VALUES (101, 'akanksha_dev', 'admin', CURRENT_DATE);

-- Query data (DQL)
SELECT * FROM users WHERE role = 'admin';

-- Grant read-only access (DCL)
GRANT SELECT ON users TO 'analyst_user';

-- Commit changes (TCL)
BEGIN;
UPDATE users SET role = 'viewer' WHERE id = 101;
COMMIT;

SQL is highly relevant in:

  • Creating and managing RDS instances in AWS

  • Provisioning databases through Terraform or CloudFormation

  • Performing log analytics in monitoring tools

  • Setting up test environments with seeded data

Learning SQL helps bridge the gap between infrastructure and the data layer, making your DevOps automation more robust and reliable.

Lesser-Known but Powerful SQL Facts

  • TRUNCATEDELETE: While both remove data, TRUNCATE is a DDL operation — it's faster, doesn't log individual row deletions, and often cannot be rolled back.

  • SQL is Declarative: Unlike procedural languages, SQL doesn’t describe how to perform tasks — just what you want. That’s why understanding optimization and indexes is so important.

  • SELECT is the Only DQL Command: Many people believe there are multiple query commands — but SELECT is the only official DQL operation.

  • SAVEPOINT lets you roll back part of a transaction: You can use SAVEPOINT and ROLLBACK TO SAVEPOINT to control specific segments of a transaction without canceling the entire block.

  • Many DevOps teams integrate SQL directly into pipelines using tools like Flyway, Liquibase, or native Jenkins scripts for database versioning, schema migration, and rollback automation.

0
Subscribe to my newsletter

Read articles from Akanksha directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Akanksha
Akanksha