Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Now that you have MySQL installed and understand the tooling, it is time to write and execute your first real SQL script. In this tutorial, you will write a complete, self-contained SQL script that creates a database, creates a table, inserts records, queries data, and explores SQL comment conventions.
Good code documentation is as important in SQL as it is in any programming language. MySQL supports three distinct commenting styles:
Copy and execute this complete script in MySQL Workbench or your CLI:
When the final SELECT query executes, MySQL returns a structured tabular result set:
+------------+---------------+----------+-----------------+ | student_id | full_name | fee_paid | enrollment_date | +------------+---------------+----------+-----------------+ | 1 | Aarav Sharma | 15000.00 | 2026-01-10 | | 4 | Ananya Gupta | 15000.00 | 2026-02-10 | +------------+---------------+----------+-----------------+ 2 rows in set (0.00 sec)
msk_tech_academy existed; if not, it created a dedicated schema directory in its data folder.InnoDB allocated a table dictionary entry and created the table space.SELECT statement filtered the rows, returning only those matching course_name = 'Python Mastery'.In professional DevOps workflows, you rarely type SQL statements interactively one by one. You save them to a .sql script file and execute them via the CLI:
IF NOT EXISTS: Adding IF NOT EXISTS to CREATE DATABASE and CREATE TABLE prevents fatal script crashes when running initialization scripts multiple times in deployment pipelines.-- must be followed by at least one space (e.g., -- comment). Writing --comment without a space will trigger a syntax error in MySQL!;).--) for a single-line comment to be valid?.sql script file?AUTO_INCREMENT attribute on a primary key column in MySQL?schema.sql directly from the operating system shell without opening the interactive MySQL prompt?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Setting Up MySQL Workbench | Creating & Listing Databases |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.