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

Kolej Yayasan Pelajaran Johor Lab Skill 3: SQL SEMESTER 2 SESI 2020/2021

This document provides instructions for a lab skill on SQL. It includes 31 questions to test various SQL commands for manipulating data in a database table called "pet". The questions cover skills like creating and selecting databases, creating and populating a table, selecting, updating and deleting data with various criteria, sorting, pattern matching, counting rows and deleting records from the table. The lab aims to help students learn and practice essential SQL data manipulation skills.

Uploaded by

Hafiz JR
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)
43 views3 pages

Kolej Yayasan Pelajaran Johor Lab Skill 3: SQL SEMESTER 2 SESI 2020/2021

This document provides instructions for a lab skill on SQL. It includes 31 questions to test various SQL commands for manipulating data in a database table called "pet". The questions cover skills like creating and selecting databases, creating and populating a table, selecting, updating and deleting data with various criteria, sorting, pattern matching, counting rows and deleting records from the table. The lab aims to help students learn and practice essential SQL data manipulation skills.

Uploaded by

Hafiz JR
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

KOLEJ YAYASAN PELAJARAN JOHOR

LAB SKILL 3: SQL

SEMESTER 2 SESI 2020/2021


CODE COURSE : DDWC2483
COURSE NAME : DATABASE
PROGRAM / SEM : DDWC - DIPLOMA SAINS KOMPUTER
(TEKNOLOGI MAKLUMAT) / 4
DURATION : 1 HOUR
DATE : 2021

INSTRUCTIONS

Answer ALL questions.


This Lab skill contributes for 3% of the total marks for the coursework.

STUDENT TOTAL
QUESTION CLO PLO/TAXANOMY MARK MARK
M % M %
Question CLO2 PLO2/C3/P4 33 3.0
TOTAL ___M ___ % 33M 3.0%

NAME : …………………………………………………………………….
MATRIC NO : …………………………………………………………………….
GROUP : …………………………………………………………………….
DATE : …………………………………………………………………….
LECTURER : FARHANA BINTI AZHARI
This paper consists of 3 pages including the cover
SQL : Data Manipulation

Create and Using a Database


1) SHOW DATABASES;

Creating and Selecting a Database


2) CREATE DATABASE nama;
3) USE nama;

Creating a Table
4) SHOW TABLES;
5) CREATE TABLE pet (name VARCHAR (20), owner VARCHAR (20), species VARCHAR (20), sex
CHAR(1), birth DATE, death DATE);
6) SHOW TABLES;
7) DESCRIBE pet;

Loading Data into a Table


8) INSERT INTO pet VALUES (‘Puffball’, ‘Diane’, ‘hamster’, ‘f’, ‘1990-03-30’, NULL);
 Masukkan semua data yang terdapat pada rajah dibawah ke dalam Table pet

Selecting ALL Data


9) SELECT * FROM pet;
10) UPDATE pet SET birth = ‘1989-08-31’ WHERE name =’Browser’;
11) DELETE FROM pet;

Selecting Particular Rows


12) SELECT * FROM pet WHERE name=’Browser’;
13) SELECT * FROM pet WHERE birth >=’1998-1-1’;
14) SELECT * FROM pet WHERE species=’dog’ AND sex=’f’;
15) SELECT * FROM pet WHERE species=’snake’ OR species=’bird’;
16) SELECT * FROM pet WHERE (species=’cat’ AND sex=’m’) OR (species=’dog’ AND sex=’f ’);
Selecting Particular Columns
17) SELECT name, birth FROM pet;
18) SELECT owner FROM pet;
19) SELECT DISTINCT owner FROM pet;
20) SELECT name, species, birth FROM pet WHERE species =’dog’ OR species =’cat’;

Sorting Rows
21) SELECT name, birth FROM pet ORDER BY birth;
22) SELECT name, birth FROM pet ORDER BY birth DESC;
23) SELECT name, species, birth FROM pet ORDER BY species, birth DESC;

Pattern Matching
24) SELECT * FROM pet WHERE name LIKE ‘b%’; (bermula dengan b)
25) SELECT * FROM pet WHERE name LIKE ‘%fy’; (berakhir dengan fy)
26) SELECT * FROM pet WHERE name LIKE ‘%b%’;
27) SELECT * FROM pet WHERE name LIKE ‘________’;

Counting Rows
28) SELECT COUNT (*) FROM pet;
29) SELECT owner, COUNT(*) FROM pet GROUP BY owner;
30) SELECT species, COUNT(*) FROM pet GROUP BY species;
31) SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
32) SELECT species, sex, COUNT(*) FROM pet WHERE species =’dog’ OR species = ‘cat’ GROUP BY
species, sex;

Delete Record From Table


33) DELETE FROM pet;

You might also like