MySQL Creating a table


Table operations in MySQL involve creating, modifying, and managing tables within a database. Tables are the core structures where data is stored in a relational database, and performing operations on them is crucial for managing data effectively. Here’s an overview of common table operations in MySQL:

1. Creating a Table

To create a new table, use the CREATE TABLE statement. You define the table name and specify its columns, their data types, and constraints.

Syntax:

CREATE TABLE table_name ( column1 data_type [constraints], column2 data_type [constraints], ... );

Example:

CREATE TABLE employees ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, position VARCHAR(100), salary DECIMAL(10, 2), hire_date DATE );

This creates a table named employees with columns for id, name, position, salary, and hire_date.