0% found this document useful (0 votes)
4 views3 pages

SQL Q

The document outlines SQL commands for creating and manipulating a database named PETSHOP, including creating a table called PETS, inserting records, and performing various queries and updates. It details operations such as modifying table structures, filtering records based on conditions, and deleting specific entries. The instructions cover both Data Definition Language (DDL) and Data Manipulation Language (DML) aspects of SQL.

Uploaded by

JC Lim
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)
4 views3 pages

SQL Q

The document outlines SQL commands for creating and manipulating a database named PETSHOP, including creating a table called PETS, inserting records, and performing various queries and updates. It details operations such as modifying table structures, filtering records based on conditions, and deleting specific entries. The instructions cover both Data Definition Language (DDL) and Data Manipulation Language (DML) aspects of SQL.

Uploaded by

JC Lim
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/ 3

BDD4213 BUSINESS SYSTEMS DEVELOPMENT SQL

1. Create a database called PETSHOP and start using it.

Data Definition Language (DDL)

2. Create a table called PET in the PETSHOP database that has the following structure.

3. Reduce the length of PetName to 15.

4. Rename the table PET to PETS.

5. Set the PetName to be unique.

6. Because some pets might have the same name, remove the unique property from
PetName.

1
BDD4213 BUSINESS SYSTEMS DEVELOPMENT SQL

If only change scooby weight :


Data Manipulation Language (DML)
UPDATE PETS
SET PetWeight = 5
7. Enter the following records into the table. WHERE PetID = 1;
Scooby 3 4.5 Dog Male
Kitty 2 1.75 Cat Female INSERT INTO PETS
Tootsy 4 2.77 Cat Female ( PetName, PetAge, PetWeight,
Rover 9 10.44 Dog Male PetType,PetGender)
Chick 2 0.5 Bird Female VALUES ('Scooby', 3 , 4.5 , 'Dog' , 'Male');
Tweety 3 0.25 Bird Male
Sylvester 5 8.2 Cat Male
INSERT INTO PETS
Nemo 2 - Fish Male
( PetName, PetAge, PetWeight,
Coco 2 3.38 Dog Female PetType,PetGender)
Dory 1 - Fish Female VALUES ('Nemo', 2 , Null , 'Fish' , 'Male');

8. View all records in table PETS. SELECT * from PETS;

9. List the pet types without any repetitions as shown below.

SELECT * from PETS


10. List those pets which are not Birds whose weight is below 5 kg. WHERE PetType != 'Bird' AND PetWeight < 5;

11. List the Male pets which are Dogs and Cats. Use the IN operator. Display only the
Petname, PetType and PetAge.

12. Sort the record in descending order for PetAge and ascending order for PetWeight.

13. Display the records of pets whose weight is between 3 kg and 8 kg. Use the between
keyword.

UPDATE PETS
14. Edit the PetName of the 5th record to “Chicky” and the Petweight to 0.65.
SET PetName = 'Chicky'
SET PetWeight = 0.65
15. List the pets without weight. WHERE PetID = 5 ;

2
BDD4213 BUSINESS SYSTEMS DEVELOPMENT SQL

16. Search for pets whose names ends with “ty”. Use wildcard for this question.

17. Show the list of pets with age and weight are less than 5.

SELECT * from PETS


WHERE PetAge < 5 AND PetWeight < 5;

18. Delete records 3 and 9 in one statement.

DELETE from PETS


where PetID = 3 , 9 ;

You might also like