CRUD operation in MySQL as easy as possible with query, query syntax & output.
Creating database & tables using create statement.
1.create command: – Create command is use to create database and tables.
Syntax- create database databasename;
2.show command: – show command will show all the databases within the MySQL database.
3.use command: – use command is use to change your database where you would like to work.
Syntax: use databsename;
4.create table student(name varchar(20),roll_no int,addr varchar(30));
5.desc command: – desc command is use to describe the table structure.
Syntax: desc tablename;
Inserting data into table using insert command.
- insert command: – insert command is use to insert the data into table.
Syntax: insert into tablename values(value1,value2,value3);
insert into tablename(feild1, feild2,feild3)values(value1,value2,value3);
select command: – select command is use to retrieve the records from table. Syntax: select * from tablename;
Retrieve data using select statement & where clause.
- Retrieve name & address from the given relation. Syntax: select column1,column2 from table_name.
where clause: where clause return the record that matches the condition. Syntax: select * from table_name where condition;
Retrieve roll no, name & address of those student with their address Shimla. Syntax: select column1,column 2,column3 from table_name where column3=condition;
Deleting data using delete statement. Delete command: delete command is use to delete the records from the relation.
Syntax: delete from table_name where condition.
Delete the record of the student where roll no is 5.
Delete records of those student with their class mca.
Delete all the records from the given relation.
Updating records using update command.
Update command: update command is use to update the records value in the table.
Syntax: update table_name set column_name=value ,column_name=value where condition;
Modify customers name f who supply part p4.
Modify part as p5 quantity as 500 of customers with customer id 102 and 103.
Modify customer id 105 who supply part p2.
Modify quantity as 200 with customer id 100,102,101.
Happy Coding 🙂