You are on page 1of 7

Activity No.

1 - SQL Data Definition Language Commands


Nepomuceno, Genesi, DL. 3/23/2021
CPE011/CPE21S1 Engr. Royce B. Chua
Database Output:
SHOW DATABASES;

CREATE DATABASE vehiclesdb;

DROP DATABASE vehiclesdb;

USE vehiclesdb;
CREATE TABLE vehicles(car_maker CHAR(20), car_model CHAR(20),number_of_doors INT);

SHOW TABLES;

DESCRIBE vehicles;

Altering the table structure


ALTER TABLE vehicles RENAME vehicle;

DESCRIBE vehicle;

ALTER TABLE vehicle MODIFY number_of_doors INT(2);

DESCRIBE vehicle;
ALTER TABLE vehicle ADD year_model DATE;

DESCRIBE vehicle;

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.
Database:

Tables:
Drivers:

Vehicles:

Tasks Syntax Actual SQL Command Used


Create a new database CREATE DATABASE CREATE DATABASE
driversdb_Nepomuceno;
Create a table named drivers CREATE TABLE CREATE TABLE drivers(ID
INT(11), FIRST_NAME
CHAR(20), LAST_NAME
CHAR(20), AGE INT(3),
ADDRESS CHAR(50), VEHICLES
INT(2), STATUS TINYINT(1));
Create a table named vehicles CREATE TABLE CREATE TABLE
vehicles(CAR_MAKER CHAR(20),
CAR_MODEL
CHAR(20),NUMBER_OF_DOORS
INT(2));
Add a new column drivers_license ALTER TABLE, ADD ALTER TABLE drivers ADD
DRIVERS_LICENSE INT;
Change the data type of ALTER TABLE, MODIFY ALTER TABLE drivers MODIFY
drivers_license DRIVERS_LICENSE CHAR(13);
Remove the field vehicles from the ALTER TABLE, DROP ALTER TABLE drivers DROP
drivers table VEHICLES;
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?
It actually works for me and it stills run but sometimes using small caps to commands
does not work I think the commands are case sensitive
2. Attempt creating a database with a similar name, but with varying capitalization. What
is the result? Why?
It creates a new database; I think it is different if you create small caps and capital database
names
3. Attempt creating a table with two similar names. What is the result? Why?
You cannot create two databases with the same name because it will issue that there is a
name that already exist.
4. Try creating two fields in table with two similar names with same then with
different datatypes. What are the results? Why?
It shows error that there is already a name in that table
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?
Yes it matter, if you don’t know the data type of the sql that you are doing you cant perform
another command
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?
I think it is capitalized so that users don’t get confused when typing and when you are
reviewing the command you can see
Conlsuion:
In this activity I learned a lot in DATABASE at how to make a simple database using SQL. Using this
application can enlighten and make use in the future in case we need to make a database.

You might also like