0% found this document useful (0 votes)
40 views2 pages

Ujian 2

The document creates two MySQL tables, Employee and AnnualReviews, to store employee and review data. It inserts sample data into both tables and runs select queries to view the inserted data. The Employee table stores information like name, ID, hire/termination dates and salary. The AnnualReviews table stores review dates linked to employee IDs.

Uploaded by

Wilson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Ujian 2

The document creates two MySQL tables, Employee and AnnualReviews, to store employee and review data. It inserts sample data into both tables and runs select queries to view the inserted data. The Employee table stores information like name, ID, hire/termination dates and salary. The AnnualReviews table stores review dates linked to employee IDs.

Uploaded by

Wilson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

create database ujian;

Query OK, 1 row affected (0.01 sec)

mysql> use ujian;


Database changed
mysql> create table Employee(FirstName varchar (25), LastName varchar (25),ID
varchar (20), HireDate date, TerminationDate date, Salary varchar (25));
Query OK, 0 rows affected (0.05 sec)

mysql> desc Employee;


+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| FirstName | varchar(25) | YES | | NULL | |
| LastName | varchar(25) | YES | | NULL | |
| ID | varchar(20) | YES | | NULL | |
| HireDate | date | YES | | NULL | |
| TerminationDate | date | YES | | NULL | |
| Salary | varchar(25) | YES | | NULL | |
+-----------------+-------------+------+-----+---------+-------+
6 rows in set (0.03 sec)

mysql> create table AnnualReviews(ID varchar (25), EmpID varchar (25), ReviewDate
date );
Query OK, 0 rows affected (0.02 sec)

mysql> desc AnnualReviews;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| ID | varchar(25) | YES | | NULL | |
| EmpID | varchar(25) | YES | | NULL | |
| ReviewDate | date | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql> insert into Employee (FirstName, LastName, ID, HireDate, TerminationDate,


Salary)
-> values ('Bob','Smith','1','2009-06-20','2016-01-01','10000'),
('Joe','Jarrod','2','2010-02-12',null,'20000'),('Nancy','Soley','3','2012-03-
14',null,'30000'),('Keith','Widjaja','4','2013-09-10','2014-01-01','20000'),
('Kelly','Smalls','5','2013-09-10',null,'20000'),('Frank','Nguyen','6','2015-04-
10','2015-05-01','60000');
Query OK, 6 rows affected (0.02 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> insert into AnnualReviews (ID, EmpID, ReviewDate)


-> values ('10','1','2016-01-01'),('20','2','2016-04-12'),('30','10','2015-02-
13'),('40','22','2010-10-12'),('50','11','2009-01-01'),('60','12','2009-03-03'),
('70','13','2008-12-01'),('80','1','2003-04-12'),('90','1','2014-04-30');
Query OK, 9 rows affected (0.01 sec)
Records: 9 Duplicates: 0 Warnings: 0

mysql> select * from Employee;


+-----------+----------+------+------------+-----------------+--------+
| FirstName | LastName | ID | HireDate | TerminationDate | Salary |
+-----------+----------+------+------------+-----------------+--------+
| Bob | Smith | 1 | 2009-06-20 | 2016-01-01 | 10000 |
| Joe | Jarrod | 2 | 2010-02-12 | NULL | 20000 |
| Nancy | Soley | 3 | 2012-03-14 | NULL | 30000 |
| Keith | Widjaja | 4 | 2013-09-10 | 2014-01-01 | 20000 |
| Kelly | Smalls | 5 | 2013-09-10 | NULL | 20000 |
| Frank | Nguyen | 6 | 2015-04-10 | 2015-05-01 | 60000 |
+-----------+----------+------+------------+-----------------+--------+
6 rows in set (0.00 sec)

mysql> select * from AnnualReviews;


+------+-------+------------+
| ID | EmpID | ReviewDate |
+------+-------+------------+
| 10 | 1 | 2016-01-01 |
| 20 | 2 | 2016-04-12 |
| 30 | 10 | 2015-02-13 |
| 40 | 22 | 2010-10-12 |
| 50 | 11 | 2009-01-01 |
| 60 | 12 | 2009-03-03 |
| 70 | 13 | 2008-12-01 |
| 80 | 1 | 2003-04-12 |
| 90 | 1 | 2014-04-30 |
+------+-------+------------+
9 rows in set (0.00 sec)s

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy