SQL Commands.
Shahnuma Khan
Computer Science
Elements of MYSQL
Literals
Datatype
NULL Value
Calculation Using arithmetic operators
SQL Operators
Update
1. Update tablename set columnname = newvalue
Update student set name = ‘Raj’;
It will update all the record with the given new value.
To change one particular record use update with where clause
2. Update tablename set columnname = newvalue where
columnname= searchvalue
Update student set name = ‘Raj’ where rollno=4;
Delete
Syntax : Delete from tablename
Delete from student;
It will delete all record from the table
______________________________________________________________
Syntax : Delete from tablename where columnname=value
Delete from student where rollno=3;
Queries to Practise
Create Table as given below
Add record
Display the name of those clients whose name contains ‘van’.
List records of all clients who are not from Bombay.
Display Different cities.
Display all the name having “i” in it.
Display the name of client who belong to bombay and delhi.
Display the detail of the client in descending order of the name.
6: Create a table ‘Club’ with proper Integrity constraints
and insert data as given below:
Display information about coaches whose name start with K or pay is at least 1500 or
both.
Write a query to display report showing coachname, pay, age and bonus (15% of pay)
for all coaches.
Display all the detail of female coach.
Display the total amount spent for the salary of the coaches.
Display the detail of the coach having salary more than 10000 and name start
with “s”.
Display name and date of appointment for coaches of swimming and squash.
Display the details of coaches in order of their pay.
Alter Command
ALTER TABLE - ADD Column
ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE employee ADD Email varchar(25);
ALTER TABLE - DROP COLUMN
ALTER TABLE table_name
DROP COLUMN column_name;
ALTER TABLE employee drop Email ;
ALTER TABLE - MODIFY COLUMN
ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
ALTER TABLE employee MODIFY Email varchar(35);