MySql Queries
Download MySql here
Select (mysql-installer-community-8.0.22.0.msi) and install.
- Show list of available databases.
Ans. show databases;
2. Create Database.
Ans. create database school;
3. Accessing a database.
Ans. use sakila;
4. List of tables in the selected database.
Ans. show tables;
5. Structure of table.
Ans. desc actor;
6. Selecting all column.(Complete table).
Ans. select *from actor;
7. View selected Coolum's from the table.
Ans. select actor_id,first_name from actor;
8. Reordering columns.
Ans. select first_name,actor_id,last_name from actor;
9. change database.
Ans. use gvkcv;
10. Create a table with the name student2
Ans.
11. Create a table student3 with fields rollno,name,class and marks. Any attempt to enter null values in the column rollno and name should be rejected.
12. Insert values into the table student3
Ans.
13.Select all the column and show the data.
14.Inserting data from another table.
15. Modifying data with update command.
16. Deleting data with delete command.
17. Drop table command.
mysql> drop table student4;
Query OK, 0 rows affected (0.74 sec)
18. Alter table command.
a)Alter table- Add column
b) Alter table-Add column in the selected place
c)Alter table-Add an integrity constraint
d)Alter table-Modify data type and Size
e)Alter table-Modify order of column
f)Alter table-Modify default value
g)Alter table-Modify NOT NULL column constraint
h)Alter table-Change Column name
i)Alter table -Drop column
19. Create a student table and insert data. Implement the following SQL commands on the student table:
ALTER table to add new attributes / modify data type / drop attribute
UPDATE table to modify data
ORDER By to display data in ascending / descending order
DELETE to remove tuple(s)
GROUP BY and find the min, max, sum, count and average