How to delete data inside MySQL table

If you want to delete a record from any MySQL table then you can use the delete command. The delete command is very similar to the update command.

delete from table where where_condition;

The delete statement deletes rows from a table.
The table is the table name.
The where clause specifies the conditions that identify which rows to delete.

How to update data inside MySQL table

Here's how to update existing data into MySQL database table.

update table set column='new_value' where where_condition;

The update statement updates columns of existing rows in the table with new values.
The table is the table name.
The set clause indicates which column to modify and the values they should be given.

How to insert data into MySQL table

Here is a general form of insert command:

insert into table (column1, column2) values (value1, value2);

The insert statement inserts new row into an existing table. The table is the name of the table into which we want to insert data, column1 and column2 are column names and value1, value2 are values for the respective columns.


How to show MySQL table details?

Issue this command in your MySQL prompt to show table column detail.

desc user;


describe user;

The display would be as follows:

How display database tables in MySQL?

Switch to a database you want to use using this command:

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Once you have selected the database, just type this command to show all the tables inside it.

mysql> show tables;

The database tables are shown below.

How to delete MySQL database?

To delete MySQL database, just simply type this command inside MySQL terminal.

mysql> drop database test_db;
Query OK, 0 rows affected (0.07 sec)

How to create MySQL database using mysqladmin command?

To create MySQL database using mysqladmin command, type this command in your terminal.

mysqladmin create database_name

How to create MySQL database?

Login to your MySQL database server

mysql -u root -p

and type this command:

mysql> create database test_db;
Query OK, 1 row affected (0.00 sec)

To check your newly created database, type this command:

mysql> show databases;
| Database           |
| information_schema | 
| mysql              | 
| test               | 
| test_db            | 
4 rows in set (0.00 sec)
Syndicate content