A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/mysql/mysql-create-table/ below:

MySQL CREATE TABLE - GeeksforGeeks

MySQL CREATE TABLE

Last Updated : 23 Jul, 2025

Creating tables in MySQL is a fundamental task for organizing and managing data within a database. Tables act as structured containers, similar to spreadsheets, where data is stored in rows and columns. In this article, we will explore the process of creating tables in MySQL using both the Command Line Interface (CLI) and MySQL Workbench.

MySQL CREATE TABLE

MySQL provides multiple methods for creating tables. The two primary methods include using the Command Line Interface(CLI) and the Graphical User Interface(GUI) provided by MySQL Workbench.

MySQL CREATE TABLE using Command Line Client

MySQL Command Line Client allows you to create a table using the CREATE TABLE statement. This method requires specifying the table name, column names, and data types. The syntax is as follows:

CREATE TABLE table_name (
    column1_name datatype constraints,
    column2_name datatype constraints,
    ...
    columnN_name datatype constraints
);

Parameters:

MySQL CREATE TABLE Example

Here's how you can do it using MySQL Command Line Client:

mysql -u your_username -p

Replace your_username with your MySQL username. You'll be prompted to enter your password.

CREATE TABLE employees (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    age INT,
    department VARCHAR(100),
    salary DECIMAL(10, 2)
);

Query:

DESCRIBE employees;

This will display the structure of the employees table, confirming that it has been created with the specified columns.

Output:

Output

Explanation: This output displays the structure of the employees table, providing information about each column as specified in the CREATE TABLE command.

By following these steps, you have successfully created a table in the MySQL command-line interface to store information about employees. The created table is now ready to be populated with data and used in your MySQL database.

MySQL CREATE TABLE using MySQL Workbench

For those who prefer a more visual approach, MySQL Workbench is a powerful tool. Follow these steps to create a table using MySQL Workbench:

To create the Table follow below given steps.

Step 1: Open MySQL Workbench and Connect to Server Step 2: Create a Database (if necessary) Step 2: Select The Database Select database Step 4: Creating Table
  1. Click on the "Create a new Table" button in the toolbar.
Create Table

Hence the Information table is successfully created using the MYSQL Workbench.

Step 5: Verify the Table Step 6: Verification in the Command Line Describe Table

By following these steps, you can easily create a table using MySQL Workbench and verify it using the MySQL Command Line Client.

Conclusion

In conclusion, creating tables in MySQL helps you organize and manage your data effectively. This guide showed you two main methods: using the Command Line Interface (CLI) and MySQL Workbench. By learning these methods, you can easily set up and handle MySQL tables, whether you prefer typing commands or using a visual tool. This flexibility makes MySQL a great choice for managing your database.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4