Menu

MySQL Databases and Tables

Create and manage MySQL databases, tables, columns, keys, constraints, and data types with practical schema guides.

This chapter introduces the operations related to databases and tables in MySQL, including creating and deleting databases, creating and deleting tables, modifying table columns, primary keys, data constraints, and data types.

  1. MySQL NULL Values

    Understand how MySQL treats NULL in comparisons, filters, sorting, grouping, aggregates, unique indexes, and null-handling functions.
  2. MySQL Create Databases

    Learn MySQL CREATE DATABASE syntax, options, and examples, including how to handle Error 1007 when the database already exists.
  3. MySQL Drop Databases

    In this article, we described how to drop a database using the DROP DATABASE statement.
  4. MySQL Use Database

    Learn how to select and switch MySQL databases, check the current database, and troubleshoot Errors 1046 and 1049.
  5. MySQL Create Tables

    Create MySQL tables with CREATE TABLE. See a practical InnoDB example with columns, defaults, AUTO_INCREMENT, primary and unique keys, and IF NOT EXISTS.
  6. MySQL Drop Tables

    Learn MySQL DROP TABLE syntax, protect existing data, and handle Error 1051 when a table in the drop list is missing.
  7. MySQL Alters Tables

    Learn MySQL ALTER TABLE syntax to add or drop columns, indexes, and constraints, rename objects, and safely change column definitions.
  8. MySQL Truncate Tables

    In this article, we described how to use the TRUNCATE TABLE statement to truncate a table.
  9. MySQL Primary Keys

    In this article, we will learn what primary keys are, the rules of primary keys, and how to use primary keys in MySQL.
  10. MySQL Foreign Keys

    Learn MySQL foreign-key syntax, parent-child rules, constraint naming, ON DELETE and ON UPDATE actions, and common troubleshooting steps.
  11. MySQL Lock Tables

    In this article, you will learn how to acquire and release table locks using MySQL LOCK TABLES and UNLOCK TABLES statements.
  12. MySQL Drop Columns

    In this article, you will learn how to drop one or more columns from a table using MySQL ALTER TABLE ... DROP COLUMN statements.
  13. MySQL Add Columns

    Learn to add MySQL table columns with ALTER TABLE ... ADD COLUMN, check the current schema, and troubleshoot Error 1060 if a column already exists.
  14. MySQL Auto Increment Columns

    In this article, we will introduce MySQL auto-increment columns and how to use auto-increment columns to generate unique identifiers.
  15. MySQL CHECK Constraints

    Learn MySQL CHECK constraint syntax, examples, NULL behavior, version support, and how to add constraints to existing tables.
  16. MySQL Rename Tables

    In this article, you will learn how to rename a table using MySQL RENAME TABLE and ALTER TABLE statements.
  17. MySQL Generated Columns

    In this article, we’ll introduce the usage of generated columns in MySQL.
  18. MySQL Unique Keys

    In this article, we describe how to use unique keys/unique indexes in MySQL to ensure that the values ​​of one or several columns are unique.
  19. MySQL NOT NULL

    Learn MySQL NOT NULL constraints, how to define or remove them, and how to distinguish Error 1048 from a missing-default error.
  20. MySQL Charset and Collation

    Learn how MySQL character sets encode text and how collations control sorting and comparison rules.