0% found this document useful (0 votes)
3 views46 pages

SQL Commands

Uploaded by

shahpratham2112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views46 pages

SQL Commands

Uploaded by

shahpratham2112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

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);

You might also like