0% found this document useful (0 votes)
418 views

Hands-On Activity 1.1 SQL Data Definition Language Commands

1. The document describes using SQL Data Definition Language commands to create, modify, and delete databases and tables in MySQL. 2. Tasks included creating databases and tables, adding and modifying columns, and displaying database and table structures. 3. Key commands used were CREATE DATABASE, CREATE TABLE, ALTER TABLE, DROP TABLE, SHOW DATABASES, and DESCRIBE.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
418 views

Hands-On Activity 1.1 SQL Data Definition Language Commands

1. The document describes using SQL Data Definition Language commands to create, modify, and delete databases and tables in MySQL. 2. Tasks included creating databases and tables, adding and modifying columns, and displaying database and table structures. 3. Key commands used were CREATE DATABASE, CREATE TABLE, ALTER TABLE, DROP TABLE, SHOW DATABASES, and DESCRIBE.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Activity Name #1 – SQL Data Definition Language Commands

Collantes, Mark Kyle, G. 10/16/2021


BSCPE - CPE21S3 Engr. Roman M. Richard

6. Database Output:

SHOW DATABASES – It shows the


default databases and databases
that I created.

CREATE DATABASE vehiclesdb – I


created a database with the name
“vehidclesdb”.

DROP DATABASE vehiclesdb – I


removed a database with the name
“vehiclesdb”.

USE vehiclesdb – It makes me use a


database with the name “vehiclesdb”.
CREATE TABLE vehicles – I
created a table with the name
“vehicles” with attributes.

SHOW TABLES – it will show you the


tables in the database that you created.

DESCRIBE vehicles –
This command will show
you the attributed in
the table that you
created.

Rename the table.

Change the value of the


attribute in the table.
Add an attribute to the
table.

Change the name of the


attribute in the table.

Cannot drop the nonexistent


table.

ALTER TABLE vehicle


RENAME vehicles
7. Supplementary Activity:
Tasks
1. Create a new database driversdb_<LASTNAME>. Show the new list of databases on the
MySQL monitor.
2. Create a table named drivers with the following attributes:
• ID
• First Name
• Last Name
• Age
• Address
• Vehicles
• Years driving
• Status
Note: (Active or Not Active)
3. Create another tabled named vehicles with the following attributes:
• Car Maker
• Car Model
• Number of Doors
4. Display all the structure for each table. Place a screenshot of your tables in the initial output.
5. Add a new column on drivers called drivers_license with data type int.
6. Change the column of drivers_license data type to a CHAR(13)
7. Remove the field vehicles from the drivers table.
8. Display all the structure for each table. Place a screenshot of your tables in the final output.
Note: Do not drop the database or any tables.
9. Cite the commands used for this activity and its output per number using the table below:

Tasks Syntax Actual SQL


Command Used
Create a new CREATE DATABASE
database driversdb_COLLANTES;

Create a table CREATE TABLE


named drivers(ID int,
drivers firstName varchar(25),
lastName varchar(25),
Age int, Address
varchar(50), Vehicles
varchar(25),
yearsDriving int,
Status varchar(25));
Create a table CREATE TABLE
named vehicles(carMaker
vehicles char(20), carModel
char(20),
Numberofdoors int);

Add a new column ALTER TABLE drivers


to ADD driversLicense
drivers_license int

Change the data ALTER TABLE drivers


type MODIFY driversLicense
of drivers_license char(13);

Remove the field ALTER TABLE drivers


vehicles from the DROP Vehicles;
drivers table.
INITIAL OUTPUT

FINAL OUTPUT
Questions:
1. Try and run your SQL Commands in opposite case or in mixed cases (ex.
SHOW TABLES – show tables). What is the output and what is the feature of
SQL that you can see in doing this task?

Because MySQL is case-insensitive, the results are identical.


2. Attempt creating a database with a similar name, but with varying
capitalization. What is the result? Why?

Because MySQL is case-insensitive, it can't create a database that already


exists.
3. Attempt creating a table with two similar names. What is the result? Why?
Because MySQL is case-insensitive, the table already exists.

4. Try creating two fields in table with two similar names with same then
with different data types. What are the results? Why?
Because MySQL is case-insensitive, there is a duplicate column
name.

5. From the output of Question #4. How does MySQL perform the check to
determine the output the result in Question#4? Does its data type matter?
MySQL examines the column name to see whether it exists. It didn't matter
what data type it was if it already existed.

6. Why do you think the keywords in SQL commands written in the instructions
of this manual and online references are capitalized? Does it affect the query
in anyway? Why?
It didn't matter if the letters were capitalized, lower-case, or upper-case
because MySQL is case-insensitive.

8. Conclusion:
By using the Data Definition Language (DDL) commands in a MySQL database, I
learnt more about the Structured Query Language (SQL) in this lab exercise. I also
learnt how to build, delete, and modify databases and tables. In MySQL Server, I also
learnt how to display databases, tables, and their structures.

You might also like