Databases 4 min read

SQL DDL and DML Commands: Creating, Modifying, and Querying Databases and Tables

This article introduces the classification of SQL statements and provides practical DDL and DML commands for creating, altering, and querying databases and tables, including examples of creating databases, showing database information, and modifying table structures.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
SQL DDL and DML Commands: Creating, Modifying, and Querying Databases and Tables

The article explains how SQL statements are classified into DQL (query language), DDL (definition language), and DML (manipulation language) and lists common commands for each category.

DQL (Database Query Language) includes the SELECT statement for retrieving data from tables.

DDL (Database Definition Language) covers commands such as CREATE DATABASE , DROP DATABASE , CREATE TABLE , and DROP TABLE to define and remove databases and tables.

DML (Database Manipulation Language) includes UPDATE , INSERT , and DELETE for modifying table data.

Database operations demonstrated include creating a database with character set specifications, e.g., CREATE DATABASE db_name CHARACTER SET utf8; , dropping a database with DROP DATABASE db_name; , viewing database details using SHOW CREATE DATABASE db_name; , listing all databases with SHOW DATABASES; , checking the current database with SELECT DATABASE(); , and listing tables in a database with SHOW TABLES; .

Table operations show how to create a table: CREATE TABLE table_name (column1 datatype, column2 datatype, ...); , drop a table with DROP TABLE table_name; , view a table’s structure using DESC table_name; , and display the table creation statement with SHOW CREATE TABLE table_name; .

Modifying tables includes renaming a table ( RENAME TABLE old_name TO new_name; ), adding a column ( ALTER TABLE table_name ADD column_name VARCHAR(2); ), dropping a column ( ALTER TABLE table_name DROP column_name; ), renaming a column ( ALTER TABLE table_name CHANGE old_column new_column VARCHAR(40); ), and changing a column’s data type ( ALTER TABLE table_name MODIFY column_name DATETIME; ). Example: ALTER TABLE bank ADD birthday DATE; followed by UPDATE bank SET birthday='2020-10-10' WHERE id=1; .

The article ends with a separator line and a list of recommended reading links related to RocketMQ deployment, Redis issues, and Zabbix-agent deployment.

SQLDatabaseDDLDMLtableSQL Commands
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.