Databases 38 min read

Comprehensive MySQL Tutorial: Basics, Data Types, Operators, Functions, and Queries

This article provides a thorough, step‑by‑step guide to MySQL, covering how to install and start the server, create databases and tables, use DDL/DML/DQL statements, understand numeric, date/time and string data types, apply arithmetic, comparison, logical and bitwise operators, and leverage common built‑in functions for efficient data manipulation.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Comprehensive MySQL Tutorial: Basics, Data Types, Operators, Functions, and Queries

MySQL is a relational database system that uses SQL (Structured Query Language) as its core language; the article begins by showing how to start the MySQL service on macOS, connect with mysql -uroot -p, and create a database using CREATE DATABASE dbname; followed by USE dbname;.

It then explains the four categories of SQL statements—DDL (e.g., CREATE TABLE, DROP DATABASE), DML (e.g., INSERT INTO, UPDATE, DELETE), DQL (e.g., SELECT, WHERE, ORDER BY, LIMIT), and DCL (e.g., GRANT, REVOKE)—with concrete examples and screenshots of query results.

The guide details MySQL data types: numeric types (INTEGER, SMALLINT, DECIMAL, FLOAT, DOUBLE, BIGINT, BIT), date/time types (YEAR, TIME, DATE, DATETIME, TIMESTAMP) and their formats, and string types (CHAR, VARCHAR, BINARY, VARBINARY, TEXT, BLOB, ENUM, SET). Examples show creating tables with specific column definitions and using attributes such as ZEROFILL, UNSIGNED, and AUTO_INCREMENT.

It lists arithmetic operators (+, -, *, /, DIV, %, MOD), comparison operators (=, <>, <=>, <, <=, >, >=, BETWEEN, IS NULL, IN, LIKE, REGEXP), logical operators (NOT, AND, OR, XOR) and bitwise operators (&, |, ^, ~, >>, <<), each illustrated with sample queries and result tables.

Common MySQL functions are grouped into categories: string functions (LOWER, UPPER, CONCAT, LEFT, RIGHT, INSERT, LTRIM, RTRIM, REPEAT, TRIM, SUBSTRING, LPAD, RPAD, STRCMP, REPLACE), numeric functions (ABS, CEIL, FLOOR, MOD, ROUND, TRUNCATE, RAND), date/time functions (NOW, WEEK, YEAR, HOUR, MINUTE, MONTHNAME, CURDATE, CURTIME, UNIX_TIMESTAMP, FROM_UNIXTIME, DATE_FORMAT, DATE_ADD, DATEDIFF), flow control functions (IF, IFNULL, CASE) and miscellaneous functions (VERSION, DATABASE, USER, PASSWORD, MD5, INET_ATON, INET_NTOA). Each function is demonstrated with a short SQL snippet inside ....

Finally, the article shows how to use MySQL’s built‑in help system (e.g., ? contents, ? VARCHAR) to quickly look up syntax, and provides a list of useful resources and links for further learning.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLdatabasemysqlData Typesfunctions
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

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.