You are on page 1of 3

De Luna, Mark Joseph L.

BSIT 1 – BLK 1

Structured Query Language: Activity #3

In this exercise, you will create a database and analyze the following command using data manipulation
language.

Direction: Write the correct statements for the following instruction.

1. Create a new database called “your Lnamedb”


Syntax: mysql> create database __________db;
CREATE DATABASE delunadb;
2. Syntax: mysql> show databases;
3. Syntax: USE _____________db;
USE deluna;
4. Create a new table called “tblStudents”.
Syntax: mysql> create table if not exists tblStudents (StudID int (5), LNAME varchar (60), FNAME varchar (60),
ADDRESS varchar (30), AGE char (2), COURSE varchar (50));
5. A command that used to display the structure of an individual table.
Syntax: mysql> __________________________________________________

MariaDB[delunadb]> DESCRIBE tblStudents;

Field Type Null Key Default Extra

StudID int(5) Yes NULL

LNAME varchar (60) YES NULL

FNAME varchar (60) YES NULL

ADDRESS varchar (30) YES NULL

AGE char (2) YES NULL

COURSE varchar (50) YES NULL


6. Add records:
Syntax: mysql> INSERT INTO tblStudents VALUES (101, 'Dela Cruz', 'Juan', 'Sariaya', '25', 'BSAIS');
Syntax: mysql>INSERT INTO tblStudents VALUES (102, Santiago, 'Merianne', 'Lucena City', '20', 'BSIT');
Syntax: mysql>INSERT INTO tblStudents VALUES (103, 'Dela Cruz', 'Rhian', 'Candelaria', '18', 'BSIT');
Syntax: mysql>INSERT INTO tblStudents VALUES (104, 'Pikachu', 'Cherry Pie', 'Sariaya', '19', 'BSEd');
Syntax: mysql>INSERT INTO tblStudents VALUES (105, 'Delikado', 'Markie', 'Tayabas', '22', 'BSAIS');
7. List all the records from tblStudents.

Syntax: mysql> ______________________________________________________

MariaDB[delunadb]> SELECT * FROM tblstudents;

StudID LNAME FNAME ADDRESS AGE COURSE

101 Dela Cruz Juan Sariaya 25 BSAIS

102 Santiago Merianne Lucena City 20 BSIT

103 Dela Cruz Rhian Candelaria 18 BSIT

104 Pikachu Cherry Pie Sariaya 19 BSEd

105 Delikado Markie Tayabas 22 BSAIS

8. List the records at the column fields fname, lname and age from tblStudents taking a course of BSAIS.
Syntax: mysql> ______________________________________________________

MariaDB[delunadb]> SELECT FNAME, LNAME, AGE FROM tblstudents


WHERE
COURSE = ‘BSAIS’ ;

FNAME LNAME AGE

Juan Dela Cruz 25

Markie Delikado 22

9. List the records at the column lname, address and course from tblStudents.
Syntax: mysql> ______________________________________________________

MariaDB[delunadb]> SELECT LNAME, ADDRESS, COURSE FROM tblstudents;

LNAME ADDRESS COURSE

Dela Cruz Sariaya BSAIS

Santiago Lucena City BSIT

Dela Cruz Candelaria BSIT

Pikachu Sariaya BSEd

Delikado Tayabas BSAIS

10. Determine the records at column fields studID, lname, fname and course in tblStudents with multiple lists of studID 101,
102, 105 and 110.
Syntax: mysql> ______________________________________________________

SELECT StudID, LNAME, FNAME, COURSE


->FROM tblstudent
->WHERE
->StudID IN (101, 102, 105, 110);
11. Retrieve the records at column fields studID, lname, fname from tblstudents whose LastName start at second and end
third position with letter 'el'.
Syntax: mysql> ______________________________________________________

MariaDB[delunadb]> SELECT StudID, LNAME, FNAME


FROM tblstudents
WHERE
LNAME LIKE ‘%el%’;

StudID LNAME FNAME

101 Dela Cruz Juan

103 Dela Cruz Rhian

105 Delikado Markie

12. List the column field age in tblStudents to eliminate the duplicate rows. Syntax: mysql>
______________________________________________________

MariaDB[delunadb]>SELECT DISTINCT AGE FROM tblstudents


;

AGE

25

20

18

19

22

You might also like