Insert Into Values: Constraint, Value2 Datatype Constraint, Value3 Datatype Constraint, ... )
Insert Into Values: Constraint, Value2 Datatype Constraint, Value3 Datatype Constraint, ... )
(INSERT, UPDATE,
DELETE) AND DCL COMMANDS. (GRANT, REVOKE) (CREATION OF
USER,CREATION OF SESSION AND PRIVILEGE)
OBJECTIVE:
To get familiarize with DML commands in mysql
THEORY:
DML is short name of Data Manipulation Language which deals with data manipulation and
includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc.,
and it is used to store, modify, retrieve, delete and update data in a database.
SELECT - retrieve data from a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - Delete all records from a database table
MERGE - UPSERT operation (insert or update)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - interpretation of the data access path
LOCK TABLE - concurrency Control
Some of the syntax of common dml commands are :
INSERT
INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1 datatype
constraint, value2 datatype constraint, value3 datatype constraint, ...);
UPDATE
UPDATE table_name SET column1 = value1, column2 = value2, ...
WHERE condition;
DELETE
DELETE FROM table_name WHERE condition;
DCL:
DCL is short name of Data Control Language which includes commands such as GRANT
and mostly concerned with rights, permissions and other controls of the database system.
WORK:
QUESTION
1. Create a employee table with attributes id (Primary key), name, gender salary
(>20000), address, mobile (unique)
Ans-> CREATE TABLE employee (id int PRIMARY KEY AUTO_INCREMENT,
name varchar (30), gender varchar (10), salary bigint CHECK (salary>20000),
address varchar (30), mobile bigint UNIQUE);
4. Update the address of the employee who are from ktm and pkr to bkt
Ans-> UPDATE `employee` SET `address`='Humla' WHERE address='Peutar' OR
address= 'Pokhara';