0% found this document useful (0 votes)
4 views

MySQL Notes

The document provides instructions for basic MySQL database operations, including creating, deleting, and altering databases and tables. It details how to create a table named 'Farmer_Details', perform various modifications, insert data, and execute selection queries. Additionally, it includes examples of renaming and deleting tables and columns, as well as inserting multiple rows at once.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MySQL Notes

The document provides instructions for basic MySQL database operations, including creating, deleting, and altering databases and tables. It details how to create a table named 'Farmer_Details', perform various modifications, insert data, and execute selection queries. Additionally, it includes examples of renaming and deleting tables and columns, as well as inserting multiple rows at once.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MySQL:

Creating a database-
Create database <name_of_the_database>

Deleting a database-
Drop database <name_of_the_database>

Changing the mode of a database-


Alter database <name_of_the_database> read only=1 (this will change the mode to
read only)
Alter database <name_of_the_database> read only=0 (this will change the mode to
write mode)

Creating a table in a database-


Step 1: Select a database from the Schemas section in the left hand side by double clicking
on the database.
Now continue the table building process.

Table creation:
create table Farmer_Details(
Farmer_Name varchar(100),
Farmer_Phone long,
Farmer_Aadhar long,
Crops varchar(50),
Login_date date
);

Selecting a table/ See a table:


select *from Farmer_Details;

Renaming a table:
rename table Farmer_Details to Customers;

Deleting a table:
Drop table Farmer_Details;

Change the parts of the table:


Alter table Farmer_Details
Add Residence text;
To rename and modify column name and data respectively:
Alter table farmer_details
rename Column Crops to Produce,
modify column Login_date datetime;

To change the position of the column:


alter table farmer_details
modify Farmer_Phone long First; (at the first position)
alter table farmer_details
modify Farmer_Phone long After Residence;( from the previous position to the position
after the residence column)

To delete a column:
alter table farmer_details
drop column Login_date;
To insert a row:
insert into Farmer_details
values("2024-01-02", "Jit",789456123012, "saffron", "Sonarpur", 1234567891);

To insert multiple rows at once:


insert into Farmer_details
values("2024-01-02", "Jit",789456123012, "saffron", "Sonarpur", 1234567891),
("2024-07-12", "rydtyt",712, "saffron", "Sonarpur", 1234567891),
("2024-02-25", "Jiu,dt,td",78123012, "saffron", "Sonarpur", 1234567891),
("2025-01-02", "Jifuyl,f",6123012, "saffron", "Sonarpur", 1234567891);

To select and display certain rows with their data:


select Farmer_Name, Produce from farmer_details;

To select and display certain rows with a specific data within it:
select *from farmer_details
Where Farmer_Name="Jit";

You might also like