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.
-
MySQL NULL Values
Understand how MySQL treats NULL in comparisons, filters, sorting, grouping, aggregates, unique indexes, and null-handling functions. -
MySQL Create Databases
Learn MySQL CREATE DATABASE syntax, options, and examples, including how to handle Error 1007 when the database already exists. -
MySQL Drop Databases
In this article, we described how to drop a database using theDROP DATABASEstatement. -
MySQL Use Database
Learn how to select and switch MySQL databases, check the current database, and troubleshoot Errors 1046 and 1049. -
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. -
MySQL Drop Tables
Learn MySQL DROP TABLE syntax, protect existing data, and handle Error 1051 when a table in the drop list is missing. -
MySQL Alters Tables
Learn MySQLALTER TABLEsyntax to add or drop columns, indexes, and constraints, rename objects, and safely change column definitions. -
MySQL Truncate Tables
In this article, we described how to use theTRUNCATE TABLEstatement to truncate a table. -
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. -
MySQL Foreign Keys
Learn MySQL foreign-key syntax, parent-child rules, constraint naming, ON DELETE and ON UPDATE actions, and common troubleshooting steps. -
MySQL Lock Tables
In this article, you will learn how to acquire and release table locks using MySQLLOCK TABLESandUNLOCK TABLESstatements. -
MySQL Drop Columns
In this article, you will learn how to drop one or more columns from a table using MySQLALTER TABLE ... DROP COLUMNstatements. -
MySQL Add Columns
Learn to add MySQL table columns withALTER TABLE ... ADD COLUMN, check the current schema, and troubleshoot Error 1060 if a column already exists. -
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. -
MySQL CHECK Constraints
Learn MySQL CHECK constraint syntax, examples, NULL behavior, version support, and how to add constraints to existing tables. -
MySQL Rename Tables
In this article, you will learn how to rename a table using MySQLRENAME TABLEandALTER TABLEstatements. -
MySQL Generated Columns
In this article, we’ll introduce the usage of generated columns in MySQL. -
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. -
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. -
MySQL Charset and Collation
Learn how MySQL character sets encode text and how collations control sorting and comparison rules.