0% found this document useful (0 votes)
6 views9 pages

Imran

The document outlines a series of SQL commands related to database management for a customer table named 'Customer'. It includes commands for creating a database, inserting data, modifying the table structure, updating records, and querying customer information. Additionally, it demonstrates operations like adding columns, changing data types, and selecting specific customer details based on various criteria.

Uploaded by

easin7arafat
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)
6 views9 pages

Imran

The document outlines a series of SQL commands related to database management for a customer table named 'Customer'. It includes commands for creating a database, inserting data, modifying the table structure, updating records, and querying customer information. Additionally, it demonstrates operations like adding columns, changing data types, and selecting specific customer details based on various criteria.

Uploaded by

easin7arafat
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/ 9

Name : Al Imran

ID : 20234103367

Intake: 52

Section: 10

DBMS
(LAB => 1)

1.
CREATE DATABASE Imran367;

2.
CREATE TABLE Customer(

CustomerID int(5),

CustomerName varchar(15),

PurchaseIteam varchar(15),
Address varchar(10),

PostalCode int(10),

PhoneNumber int(15)

);

3.
INSERT INTO customer

VALUES

(1,'Adiba mehjabin','Three Piece','Dhanmondi',1205,0131745367),

(2,'Rafiqul Islam','Wallet','Mirpur 1',1216,0161745387),

(3,'Sanjila Islam','Kurti','UttarKhan',1106,0171748367),

(4,'Sharifa Begum','Bed sheet','Sector 7',1108,0191745388),

(5,'Amina Begum','Two Piece','Badda',1300,0131745768),

(6,'Monowara Akter','Ear ring','Mirpur 12',1217,0151845366)


(LAB => 2)

1. Add a new column with name CustomerGrade


=>
ALTER TABLE customer
ADD CustomerGrade varchar(10)

2.
Delete PostalCode column.
=>
ALTER TABLE customer
DROP COLUMN PostalCode

3. Rename address column to AddressDetails


=>
ALTER TABLE customer
CHANGE Address AddressDetails varchar(15);
4. Change the data type of phone number column.

=>

ALTER TABLE customer

MODIFY PhoneNumber varchar(15)

5. Change the purchage iteam “kurta” to “shirt”


=>

UPDATE customer

set PurchaseIteam='shirt'

WHERE CustomerID=3;

6. Add primary key in customer table.


=>

ALTER TABLE customer

ADD PRIMARY KEY (CustomerID);

7. Add value in CustomerGrade column.


=>

ALTER TABLE customer;

UPDATE customer SET CustomerGrade = 'gold' where CustomerID=1;


8. Select the information of customers whose grade is “gold”
=>

SELECT CustomerGrade

FROM customer

WHERE CustomerGrade='gold'

9. Truncate customer table.


=>

TRUNCATE TABLE customer;

10. Drop customer table.


=>

DROM TABLE customer;


(LAB => 3)

1. Find out the “Gold” customer.


SELECT * From customer

WHERE Grade='Gold';
2. Find out the information of customer who purchase “Wallet”
SELECT * FROM customer
WHERE PurchaseIteam='Wallet';

3. Find the phone number of all customer.

SELECT PhoneNumber

FROM customer

4. Find out id, address and grade of all customer.

SELECT CustomerID,Address,Grade
FROM customer
5. Find out the grade of customer who purchage “bed sheet” and whose grade
is “silver”.

SELECT * FROM customer WHERE PurchaseIteam='bed sheet' && Grade='Silver';

6.Find out the name of customer whose postal code is “1106” or whose id is “6”.
SE SELECT CustomerName FROM customer
WHERE PostalCode=1106 || CustomerID=6;

7. Find out the information of customer whose name start with “M”.
SELECT * FROM customer
WHERE CustomerName LIKE 'M%';

8. Find out the information of customer whose name end with “M”.
SELECT * FROM customer
WHERE CustomerName LIKE '%M';
9. Find out the information of customer whose name contain “M” in second position.
SELECT * FROM customer
WHERE CustomerName LIKE '_M%'

10. Find out the information of customer whose name is “Sanjila


Islam”.

SELECT * FROM customer


WHERE CustomerName='Sanjila Islam';

You might also like