How to change the table name in MySQL?

Sometimes our table name is non-meaningful. In that case, we need to change or rename the table name. MySQL provides the following syntax to rename one or more tables in the current database: mysql> RENAME old_table TO new_table; If we want to change more than one table name, use the below syntax: RENAME TABLE old_tab1 … Read more

How to change the MySQL password?

We can change the MySQL root password using the below statement in the new notepad file and save it with an appropriate name: ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘NewPassword’; Next, open a Command Prompt and navigate to the MySQL directory. Now, copy the following folder and paste it in our DOS command and press the … Read more

How to add foreign keys in MySQL?

The foreign key is used to link one or more tables together. It matches the primary key field of another table to link the two tables. It allows us to create a parent-child relationship with the tables. We can add a foreign key to a table in two ways: Using the CREATE TABLE Statement Using … Read more

How to delete a table in MySQL?

We can delete a table in MySQL using the Drop Table statement. This statement removes the complete data of a table, including structure and definition from the database permanently. Therefore, it is required to be careful while deleting a table. After using the statement, we cannot recover the table in MySQL. The statement is as … Read more

How to add columns in MySQL?

A column is a series of cells in a table that stores one value for each row in a table. We can add columns in an existing table using the ALTER TABLE statement as follows: ALTER TABLE table_name ADD COLUMN column_name column_definition [FIRST|AFTER existing_column]; To add columns to an existing table in MySQL, you can … Read more