As we know that we can use MySQL to use Structure Query Language to store the data in the form of RDBMS. SQL is the most popular language for adding, accessing, and managing content in a database. It is most noted for its quick processing, proven reliability, ease, and flexibility of use. The application is used for a wide range of purposes, including data warehousing, e-commerce, and logging applications. The most common use for MySQL, however, is for the purpose of a web database.
MySQL provides a set of some basic but most essential operations that will help you to easily interact with the MySQL database and these operations are known as CRUD operations.

1. Create Table Command :
Syntax :
CREATE TABLE table_name (column_name column_type constraints);
Parameters :
- column_name –
Name of the particular column with any space. - column_type –
Datatype of the column. Datatype depends upon the data of the reference column. Datatype can be – char(), varchar(), int(), float(), etc. - constraints –
In order to give restrictions to particular column constraints are used. Constraints can be – not null, primary key, foreign key, etc. These are the keywords which give set of restriction to the particular column.
Database – GFG
Table – Student
Student –
- name Varchar(30) NOT NULL
- marks Integer
Example :
use <database> command must be used before any operation on the table.
use gfg; Create table student(name Varchar(30) NOT NULL, marks Integer);
Output :
Field | Type | Null | Default |
name | varchar(30) | No | Null |
marks | int(11) | YES | Null |
2. Read Operation :
The Read operations are used to retrieve the content of the table from a particular database. Read operation is done by DDL commands.
Example :
use gfg; select * from student;
name | marks |
ravi | 23 |
swati | 33 |
kranti | 12 |
3. Update Operation :
Altering the content of the table or the structure of the table is done with the help of Update Operations. Two Commands are mostly used for Update Operation –
- Alter Table Command –
This is the DDL command (Data Definition Language) used to change the structure of the table.
- Update Table Command –
This is the DML command(Data Manipulating Language) used to alter the records.
Alter Table Command that change the size of name column from varchar(40) to varchar(50) for the Student table :
Alter table student modify name varchar(50) not null;
Original Table –
desc student;
Field | Type | Null | Default |
name marks | varchar(40) int(11) | YES YES | Null Null |
After altering the table –
desc student;
Field | Type | Null | Default |
name marks | varchar(50) int(11) | YES YES | Null Null |
Update Command that update the marks of the student from 23 to 100 whose name is ravi using the update command :
Update student set marks = 100 where name = "ravi";
Original Table –
select * from student;
name | marks |
ravi | 23 |
swati | 33 |
kranti | 12 |
After updating the table –
select * from student;
name | marks |
ravi | 100 |
swati | 33 |
kranti | 12 |
4. Delete Operation :
Two commands are mostly used for the Delete operations –
- Delete Command –
(DML command) works on the records of the table.
- Drop Command –
(DDL command) works on the structure of the table.
Delete Command that delete the records of students having marks equal to 100 :
delete from student where marks = 100;
Original Table –
select * from student;
name | marks |
ravi | 100 |
swati | 33 |
kranti | 12 |
After deleting the student records –
select * from student;
name | marks |
swati | 33 |
kranti | 12 |
Drop Command that drop the table student :
drop table student;
Original Structure –
use gfg; show tables;
After dropping the student table –
use gfg; show tables;
Similar Reads
PHP - MySQL min(),max() aggregate operations
In this article, we are going to find minimum and maximum details from the table column using PHP from MySQL Xampp server. We are taking an example from employee database to find the minimum and maximum salary of the employee. Requirements -Xampp server Introduction : PHP - It stands for Hyper Text
4 min read
PHP - MYSQL : sum() operation
Problem Statement: In this article, we are going to perform sum() aggregate operation on our database using PHP with xampp server. So we are considering the food_order database and perform database sum() operation. Requirements: xampp Introduction: PHP stands for hypertext preprocessor which is a se
3 min read
Python MySQL - BETWEEN and IN Operator
In this article, we are going to see the database operations BETWEEN and IN operators in MySQL using Python. Both of these operators are used with the WHERE query to check if an expression is within a range or in a list of values in SQL. We are going to use the below table to perform various operati
3 min read
PERIOD_ADD() function in MySQL
PERIOD_ADD() function in MySQL helps to add a specific number of months to a given period. The PERIOD_ADD() function will return the resultant value in 'YYYYMM' format. Syntax : PERIOD_ADD(period, number) Parameters : period - A period which should be in YYMM OR YYYYMM format. number - The number of
1 min read
MySQL Interview Questions
MySQL is an open-source Relational Database Management System(RDMS) that organizes data in tables using rows and columns. It uses Structured Query Language (SQL) for managing and manipulating databases. It was originally developed by MySQL AB, a Swedish company, and is now owned by Oracle Corporatio
15 min read
POWER() Function in MySQL
POWER() function in MySQL is used to find the value of a number raised to the power of another number. It Returns the value of X raised to the power of Y. Syntax : POWER(X, Y) Parameter : This method accepts two parameter which are described below : X : It specifies the base number. Y : It specifies
3 min read
TAN() Function in MySQL
TAN() function : This function in MySQL is used to return the tangent of a specified number. In any right triangle, the tangent of an angle is the length of the opposite side divided by the length of the adjacent side. Similarly, this can also be defined as tangent of x is the sine of x divided by t
1 min read
OCT() function in MySQL
OCT() function in MySQL is used to convert decimal number to octal. It returns equivalent octal value of a decimal number. Syntax : OCT(number) Parameter : This method accepts only one parameter. number : The decimal number which we want to convert. Returns : It returns octal value of a decimal numb
2 min read
MySQL | Operator precedence
Operator precedence specifies the order in which operators are evaluated when two or more operators with different precedence are adjacent in an expression. For example, 1+2/3 gives the different result as compared to (1+2)/3. Just like all other programming languages C, C++, Java etc. MySQL also ha
3 min read
SQRT() Function in MySQL
The SQRT() function in MySQL calculates the square root of a non-negative number, returning NULL for negative inputs. It is a built-in function that provides high precision and is optimized for performance and making it ideal for mathematical and scientific applications. In the article, we will cove
4 min read