MySQL COMMANDS:
Create Database
CREATE DATABASE CPS;
Display database
SHOW DATABASES;
Use Database
USE CPS;
Create Table
CREATE TABLE STUDENT
(SID VARCHAR(5) UNIQUE,
SNAME VARCHAR(30) NOT NULL,
CLASS VARCHAR(5),
ADDRESS CHAR(50),
DOB DATE,
FEES NUMERIC);
Insert value into table
INSERT INTO STUDENT (SID, SNAME, CLASS, ADDRESS, DOB, FEES)
VALUES (“S01”, “AMAN”, “10C”, “JAMSHEDPUR”, “2007-12-05”, 2000),
(“S02”, “SANJAY”, “10B”, “DELHI”, “2008-12-15”, 2000);
New value insert into table
INSERT INTO STUDENT VALUES(“S03”, “NEHA”, “10B”, “MUMBAI”, “2007-04-06”, 2000);
Display all details:
SELECT * FROM STUDENT;
Display particular column
SELECT SID, SNAME FROM STUDENT;
Arrange in order
SELECT SNAME FROM STUDENT ORDER BY SNAME; // Ascending order
SELECT SNAME FROM STUDENT ORDER BY SNAME DESC; // Descending order
Increment And Decrement in particular filed
SELECT SNAME, FEES + 500 FROM STUDENT;
SELECT SNAME, FEES – 500 FROM STUDENT;
Update the records
UPDATE STUDENT SET SNAME = “AMAN” WHERE SID =”S01”;
MySQL Questions:
1. What is DBMS? What are the advantages of DBMS.
2. What are the elements of DBMS and explain them.
3. Write any five data types in MySQL?
4. What is primary key?
5. What are the different types of keys available in MySQL? Explain them.
6. What are the different languages used in MySQL and also write their commands.
7. Ans- DDL (Data Definition Language) – CREATE, ALTER, DROP, TRUNCATE
DML ( Data Manipulation Language) – INSERT, UPDATE, DELETE
DCL (Data Control Language) – GRANT, REVOKE
TCL (Transaction Control Language) – COMMIT, ROLLBACK, SAVEPOINT
DQL ( Data Query Language) – SELECT