![]() |
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 TABLEMySQL 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 ClientMySQL Command Line Client allows you to create a table using the CREATE TABLE table_name (
column1_name datatype constraints,
column2_name datatype constraints,
...
columnN_name datatype constraints
);
Parameters:
MySQL CREATE TABLE ExampleHere’s how you can do it using MySQL Command Line Client:
mysql -u your_username -p
Replace
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 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 WorkbenchFor 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
![]() 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. ConclusionIn 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. |
Reffered: https://www.geeksforgeeks.org
Databases |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |