You are on page 1of 10

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 7


Server version: 5.5.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'datab
ase' at line 1
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| dewi_pl
|
| mysql
|
| performance_schema |
| test
|
+--------------------+
5 rows in set (0.00 sec)
mysql> use dewi_pl;
Database changed
mysql> create table employee;
ERROR 1113 (42000): A table must have at least 1 column
mysql> create table employee
-> create table employee(fname VARCHAR(15) NOT NULL,minit CHAR,lname VARCHAR
(15) NOT NULL,ssn VARCHAR(9) NOT NULL,bdate DATE,address VARCHAR(30),sex CHAR,sa
lary DECIMAL(10,2),super_ssn VARCHAR(9),dno INT,primary key (ssn),foreign key (s
uper_ssn) REFERENCES employee (ssn));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'creat
e table employee(fname VARCHAR(15) NOT NULL,minit CHAR,lname VARCHAR(15) NO' at
line 2
mysql> create table employee(fname VARCHAR(15) NOT NULL,minit CHAR,lname VARCHAR
(15) NOT NULL,ssn VARCHAR(9) NOT NULL,bdate DATE,address VARCHAR(30),sex CHAR,sa
lary DECIMAL(10,2),super_ssn VARCHAR(9),dno INT,primary key (ssn));
Query OK, 0 rows affected (0.08 sec)
mysql> describe table employee;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'table
employee' at line 1
mysql> describe employee;
+-----------+---------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| fname
| varchar(15) | NO |
| NULL
|
|
| minit
| char(1)
| YES |
| NULL
|
|
| lname
| varchar(15) | NO |
| NULL
|
|
| ssn
| varchar(9)
| NO | PRI | NULL
|
|
| bdate
| date
| YES |
| NULL
|
|
| address | varchar(30) | YES |
| NULL
|
|

| sex
| char(1)
| YES |
| NULL
|
|
| salary
| decimal(10,2) | YES |
| NULL
|
|
| super_ssn | varchar(9)
| YES |
| NULL
|
|
| dno
| int(11)
| YES |
| NULL
|
|
+-----------+---------------+------+-----+---------+-------+
10 rows in set (0.02 sec)
mysql> create table department(dname VARCHAR(15) NOT NULL,dnumber INT,mgr_ssn VA
RCHAR(9) NOT NULL,mgr_startdate DATE,primary key (dnumber));
Query OK, 0 rows affected (2.18 sec)
mysql> describe department;
+---------------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| dname
| varchar(15) | NO |
| NULL
|
|
| dnumber
| int(11)
| NO | PRI | 0
|
|
| mgr_ssn
| varchar(9) | NO |
| NULL
|
|
| mgr_startdate | date
| YES |
| NULL
|
|
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> create table dept_locations(dnumber INT NOT NULL,dlocation VARCHAR(20) NO
T NULL,primary key (dnumber,dlocation));
Query OK, 0 rows affected (0.38 sec)
mysql> describe dept_location;
ERROR 1146 (42S02): Table 'dewi_pl.dept_location' doesn't exist
mysql> describe dept_locations;
+-----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| dnumber | int(11)
| NO | PRI | NULL
|
|
| dlocation | varchar(20) | NO | PRI | NULL
|
|
+-----------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> create table project(pname VARCHAR(16) NOT NULL,pnumber INT NOT NULL,ploc
ation VARCHAR(20),dnum INT,primary key (pnumber));
Query OK, 0 rows affected (0.06 sec)
mysql> describe project;
+-----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| pname
| varchar(16) | NO |
| NULL
|
|
| pnumber | int(11)
| NO | PRI | NULL
|
|
| plocation | varchar(20) | YES |
| NULL
|
|
| dnum
| int(11)
| YES |
| NULL
|
|
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
mysql> create table work_on(essn VARCHAR(9) NOT NULL,pno INT NOT NULL,hours TIME
,primary key (essn,pno));
Query OK, 0 rows affected (0.00 sec)
mysql> describe work_on;
+-------+------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+

| essn | varchar(9) | NO | PRI | NULL


|
|
| pno | int(11)
| NO | PRI | NULL
|
|
| hours | time
| YES |
| NULL
|
|
+-------+------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> create table dependent(essn VARCHAR(9) NOT NULL,dependent_name VARCHAR(15
) NOT NULL,sex CHAR,bdate DATE,relationship VARCHAR(8),primary key (essn,depende
nt_name));
Query OK, 0 rows affected (0.05 sec)
mysql> describe dependent;
+----------------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| essn
| varchar(9) | NO | PRI | NULL
|
|
| dependent_name | varchar(15) | NO | PRI | NULL
|
|
| sex
| char(1)
| YES |
| NULL
|
|
| bdate
| date
| YES |
| NULL
|
|
| relationship | varchar(8) | YES |
| NULL
|
|
+----------------+-------------+------+-----+---------+-------+
5 rows in set (0.02 sec)
mysql> alter table employee MODIFY superssn VARCHAR(9),ADD FOREIGN KEY(ssn);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> alter table employee MODIFY superssn VARCHAR(9),ADD FOREIGN KEY(superssn)
;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> alter table employee MODIFY superssn VARCHAR(9),ADD FOREIGN KEY(superssn)
REFERENCES employee(ssn);
ERROR 1054 (42S22): Unknown column 'superssn' in 'employee'
mysql> alter table employee MODIFY superssn VARCHAR(9),ADD FOREIGN KEY(super_ssn
) REFERENCES employee(ssn);
ERROR 1054 (42S22): Unknown column 'superssn' in 'employee'
mysql> alter table employee MODIFY super_ssn VARCHAR(9),ADD FOREIGN KEY(super_ss
n) REFERENCES employee(ssn);
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe employee;
+-----------+---------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| fname
| varchar(15) | NO |
| NULL
|
|
| minit
| char(1)
| YES |
| NULL
|
|
| lname
| varchar(15) | NO |
| NULL
|
|
| ssn
| varchar(9)
| NO | PRI | NULL
|
|
| bdate
| date
| YES |
| NULL
|
|
| address | varchar(30) | YES |
| NULL
|
|
| sex
| char(1)
| YES |
| NULL
|
|
| salary
| decimal(10,2) | YES |
| NULL
|
|
| super_ssn | varchar(9)
| YES | MUL | NULL
|
|
| dno
| int(11)
| YES |
| NULL
|
|
+-----------+---------------+------+-----+---------+-------+
10 rows in set (0.00 sec)

mysql> alter table employee MODIFY dno INT,ADD FOREIGN KEY(dno) REFERENCES depar
tment(dnumber);
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe employee;
+-----------+---------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| fname
| varchar(15) | NO |
| NULL
|
|
| minit
| char(1)
| YES |
| NULL
|
|
| lname
| varchar(15) | NO |
| NULL
|
|
| ssn
| varchar(9)
| NO | PRI | NULL
|
|
| bdate
| date
| YES |
| NULL
|
|
| address | varchar(30) | YES |
| NULL
|
|
| sex
| char(1)
| YES |
| NULL
|
|
| salary
| decimal(10,2) | YES |
| NULL
|
|
| super_ssn | varchar(9)
| YES | MUL | NULL
|
|
| dno
| int(11)
| YES | MUL | NULL
|
|
+-----------+---------------+------+-----+---------+-------+
10 rows in set (0.01 sec)
mysql> alter table dept_location MODIFY dnumber INT NOT NULL,ADD FOREIGN KEY(dnu
mber) REFERENCES department(dnumber);
ERROR 1146 (42S02): Table 'dewi_pl.dept_location' doesn't exist
mysql> alter table dept_locations MODIFY dnumber INT NOT NULL,ADD FOREIGN KEY(dn
umber) REFERENCES department(dnumber);
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe dept_locations;
+-----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| dnumber | int(11)
| NO | PRI | NULL
|
|
| dlocation | varchar(20) | NO | PRI | NULL
|
|
+-----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> alter table project MODIFY dnum INT,add foreign key(dnum) REFERENCES depa
rtment(dnumber);
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe project;
+-----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| pname
| varchar(16) | NO |
| NULL
|
|
| pnumber | int(11)
| NO | PRI | NULL
|
|
| plocation | varchar(20) | YES |
| NULL
|
|
| dnum
| int(11)
| YES | MUL | NULL
|
|
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> insert into employee(fname,minit,lname,ssn,bdate,address,sex,salary,super
_ssn,dno) VALUES('John','B','Smith','123456789','1965-01-09','731 Fondren, Houst
on, TX','M',30000,'333445555',5);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`dewi_pl`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`super_ssn

`) REFERENCES `employee` (`ssn`))


mysql> insert into employee(fname,minit,lname,ssn,bdate,address,sex,salary,dno)
VALUES('John','B','Smith','123456789','1965-01-09','731 Fondren, Houston, TX','M
',30000,5);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`dewi_pl`.`employee`, CONSTRAINT `employee_ibfk_2` FOREIGN KEY (`dno`) REF
ERENCES `department` (`dnumber`))
mysql> insert into employee(fname,minit,lname,ssn,bdate,address,sex,salary) VALU
ES('John','B','Smith','123456789','1965-01-09','731 Fondren, Houston, TX','M',30
000);
Query OK, 1 row affected (0.01 sec)
mysql> describe employee;
+-----------+---------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| fname
| varchar(15) | NO |
| NULL
|
|
| minit
| char(1)
| YES |
| NULL
|
|
| lname
| varchar(15) | NO |
| NULL
|
|
| ssn
| varchar(9)
| NO | PRI | NULL
|
|
| bdate
| date
| YES |
| NULL
|
|
| address | varchar(30) | YES |
| NULL
|
|
| sex
| char(1)
| YES |
| NULL
|
|
| salary
| decimal(10,2) | YES |
| NULL
|
|
| super_ssn | varchar(9)
| YES | MUL | NULL
|
|
| dno
| int(11)
| YES | MUL | NULL
|
|
+-----------+---------------+------+-----+---------+-------+
10 rows in set (0.05 sec)
mysql> SELECT*FROM EMPLOYEE;
+-------+-------+-------+-----------+------------+--------------------------+-----+----------+-----------+------+
| fname | minit | lname | ssn
| bdate
| address
| se
x | salary | super_ssn | dno |
+-------+-------+-------+-----------+------------+--------------------------+-----+----------+-----------+------+
| John | B
| Smith | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX | M
| 30000.00 | NULL
| NULL |
+-------+-------+-------+-----------+------------+--------------------------+-----+----------+-----------+------+
1 row in set (0.00 sec)
mysql> UPDATE employee set super_ssn='333445555',dno=5 where ssn='123456789';
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`dewi_pl`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`super_ssn
`) REFERENCES `employee` (`ssn`))
mysql> UPDATE employee set super_ssn='333445555' where ssn='123456789';
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`dewi_pl`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`super_ssn
`) REFERENCES `employee` (`ssn`))
mysql> alter table project MODIFY dnum INT,add foreign key(dnum) REFERENCES depa
rtment(dnumber);
mysql> update employee set super_ssn='8886655555' where ssn='333445555';
ERROR 1406 (22001): Data too long for column 'super_ssn' at row 1
mysql> update employee set super_ssn='888665555' where ssn='333445555';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update employee set super_ssn='987654321' where ssn='999887777';


Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set super_ssn='888665555' where ssn='987654321';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set super_ssn='333445555' where ssn='666884444';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set super_ssn='333445555' where ssn='453453453';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set super_ssn='987654321' where ssn='987987987';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set super_ssn='' where ssn='888665555';
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`dewi_pl`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`super_ssn
`) REFERENCES `employee` (`ssn`))
mysql> insert into department(dname,dnumber,mgr_ssn,mgr_startdate) values('Resea
rch',5,'333445555','1988-05-22');
Query OK, 1 row affected (0.41 sec)
mysql> insert into department(dname,dnumber,mgr_ssn,mgr_startdate) values('Admin
istration',4,'987654321','1995-01-01');
Query OK, 1 row affected (0.00 sec)
mysql> insert into department(dname,dnumber,mgr_ssn,mgr_startdate) values('Headq
uarters',1,'888665555','1981-06-19');
Query OK, 1 row affected (2.06 sec)
mysql> update employee set dno=5 where ssn='987987987';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=5 where ssn='123456789';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=5 where ssn='333445555';
Query OK, 1 row affected (2.11 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=4 where ssn='999887777';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=4 where ssn='987654321';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=5 where ssn='666884444';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update employee set dno=5 where ssn='453453453';


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=4 where ssn='987987987';
Query OK, 1 row affected (0.38 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update employee set dno=1 where ssn='888665555';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select*from employee;
+----------+-------+---------+-----------+------------+-------------------------+------+----------+-----------+------+
| fname
| minit | lname | ssn
| bdate
| address
| sex | salary | super_ssn | dno |
+----------+-------+---------+-----------+------------+-------------------------+------+----------+-----------+------+
| John
| B
| Smith | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX
| M
| 30000.00 | 333445555 |
5 |
| Franklin | T
| Wong
| 333445555 | 1955-12-08 | 638 Voss, Houston, TX
| M
| 40000.00 | 888665555 |
5 |
| Joyce
| A
| English | 453453453 | 1972-07-31 | 5631 Rice, Houston, TX
| F
| 25000.00 | 333445555 |
5 |
| Ramesh | K
| Narayan | 666884444 | 1962-09-15 | 975 Fire Oak, Humble, TX
| M
| 38000.00 | 333445555 |
5 |
| James
| E
| Borg
| 888665555 | 1937-11-10 | 450 Stone, Houston, TX
| M
| 55000.00 | NULL
|
1 |
| Jennifer | S
| Wallace | 987654321 | 1941-06-20 | 291 Berry, Bellaire, TX
| M
| 43000.00 | 888665555 |
4 |
| Ahmad
| V
| Jabbar | 987987987 | 1969-03-29 | 980 Dallas, Houston, TX
| M
| 25000.00 | 987654321 |
4 |
| Alicia | J
| Zelaya | 999887777 | 1968-01-19 | 3312 Castle, Spring, TX
| F
| 25000.00 | 987654321 |
4 |
+----------+-------+---------+-----------+------------+-------------------------+------+----------+-----------+------+
8 rows in set (0.02 sec)
mysql> select*from department;
+----------------+---------+-----------+---------------+
| dname
| dnumber | mgr_ssn | mgr_startdate |
+----------------+---------+-----------+---------------+
| Headquarters |
1 | 888665555 | 1981-06-19
|
| Administration |
4 | 987654321 | 1995-01-01
|
| Research
|
5 | 333445555 | 1988-05-22
|
+----------------+---------+-----------+---------------+
3 rows in set (0.00 sec)
mysql> insert into dept_location(dnumber,dlocation) values(1,'Houston');
ERROR 1146 (42S02): Table 'dewi_pl.dept_location' doesn't exist
mysql> insert into dept_locations(dnumber,dlocation) values(1,'Houston');
Query OK, 1 row affected (0.11 sec)
mysql> insert into dept_locations(dnumber,dlocation) values(4,'Stafford');
Query OK, 1 row affected (0.00 sec)
mysql> insert into dept_locations(dnumber,dlocation) values(5,'Bellaire');
Query OK, 1 row affected (0.00 sec)

mysql> insert into dept_locations(dnumber,dlocation) values(5,'Sugarland');


Query OK, 1 row affected (0.00 sec)
mysql> insert into dept_locations(dnumber,dlocation) values(5,'Houston');
Query OK, 1 row affected (0.02 sec)
mysql> select*from dept_locations;
+---------+-----------+
| dnumber | dlocation |
+---------+-----------+
|
1 | Houston |
|
4 | Stafford |
|
5 | Bellaire |
|
5 | Houston |
|
5 | Sugarland |
+---------+-----------+
5 rows in set (0.00 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('ProductX',1,'Be
llaire',5);
Query OK, 1 row affected (0.09 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('ProductY',2,'Su
garland',5);
Query OK, 1 row affected (0.00 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('ProductZ',3,'Ho
uston',5);
Query OK, 1 row affected (0.02 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('Computerization
',10,'Stafford',4);
Query OK, 1 row affected (2.14 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('Reorganization'
,20,'Houston',1);
Query OK, 1 row affected (0.00 sec)
mysql> insert into project(pname,pnumber,plocation,dnum) values('Newbenefit',30,
'Stafford',4);
Query OK, 1 row affected (0.00 sec)
mysql> select*from project;
+-----------------+---------+-----------+------+
| pname
| pnumber | plocation | dnum |
+-----------------+---------+-----------+------+
| ProductX
|
1 | Bellaire |
5 |
| ProductY
|
2 | Sugarland |
5 |
| ProductZ
|
3 | Houston |
5 |
| Computerization |
10 | Stafford |
4 |
| Reorganization |
20 | Houston |
1 |
| Newbenefit
|
30 | Stafford |
4 |
+-----------------+---------+-----------+------+
6 rows in set (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('123456789',1,'32.5');
Query OK, 1 row affected (2.17 sec)
mysql> insert into work_on(essn,pno,hours) values('123456789',2,'7.5');
Query OK, 1 row affected (0.00 sec)

mysql> insert into work_on(essn,pno,hours) values('666884444',3,'40.0');


Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('453453453',1,'20.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('453453453',2,'20.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('333445555',2,'10.0');
Query OK, 1 row affected (0.02 sec)
mysql> insert into work_on(essn,pno,hours) values('333445555',3,'10.0');
Query OK, 1 row affected (0.05 sec)
mysql> insert into work_on(essn,pno,hours) values('333445555',10,'10.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('333445555',20,'10.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('999887777',30,'30.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('999887777',10,'10.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('987987987',10,'35.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('987987987',30,'5.0');
Query OK, 1 row affected (0.01 sec)
mysql> insert into work_on(essn,pno,hours) values('987654321',30,'20.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('987654321',20,'15.0');
Query OK, 1 row affected (0.00 sec)
mysql> insert into work_on(essn,pno) values('888665555',20);
Query OK, 1 row affected (0.34 sec)
mysql> select*from work_on;
+-----------+-----+----------+
| essn
| pno | hours
|
+-----------+-----+----------+
| 123456789 | 1 | 00:00:32 |
| 123456789 | 2 | 00:00:07 |
| 333445555 | 2 | 00:00:10 |
| 333445555 | 3 | 00:00:10 |
| 333445555 | 10 | 00:00:10 |
| 333445555 | 20 | 00:00:10 |
| 453453453 | 1 | 00:00:20 |
| 453453453 | 2 | 00:00:20 |
| 666884444 | 3 | 00:00:40 |
| 888665555 | 20 | NULL
|
| 987654321 | 20 | 00:00:15 |
| 987654321 | 30 | 00:00:20 |
| 987987987 | 10 | 00:00:35 |

| 987987987 | 30 | 00:00:05 |
| 999887777 | 10 | 00:00:10 |
| 999887777 | 30 | 00:00:30 |
+-----------+-----+----------+
16 rows in set (0.00 sec)
mysql> insert into work_on(essn,pno,hours) values('888665555',20,);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ')' at
line 1
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'333445555','Alice','F','1986-04-05','Daughter');
Query OK, 1 row affected (0.08 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'333445555','Theodore','M','1983-10-25','Son');
Query OK, 1 row affected (2.12 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'333445555','Joy','F','1958-05-03','Spouse');
Query OK, 1 row affected (0.00 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'987654321','Abner','M','1942-02-28','Spouse');
Query OK, 1 row affected (0.00 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'123456789','Michael','M','1988-01-04','Son');
Query OK, 1 row affected (0.00 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'123456789','Alice','F','1988-12-30','Daughter');
Query OK, 1 row affected (0.00 sec)
mysql> insert into dependent(essn,dependent_name,sex,bdate,relationship) values(
'123456789','Elizabeth','F','1967-05-05','Spouse');
Query OK, 1 row affected (0.00 sec)
mysql> select*from dependent;
+-----------+----------------+------+------------+--------------+
| essn
| dependent_name | sex | bdate
| relationship |
+-----------+----------------+------+------------+--------------+
| 123456789 | Alice
| F
| 1988-12-30 | Daughter
|
| 123456789 | Elizabeth
| F
| 1967-05-05 | Spouse
|
| 123456789 | Michael
| M
| 1988-01-04 | Son
|
| 333445555 | Alice
| F
| 1986-04-05 | Daughter
|
| 333445555 | Joy
| F
| 1958-05-03 | Spouse
|
| 333445555 | Theodore
| M
| 1983-10-25 | Son
|
| 987654321 | Abner
| M
| 1942-02-28 | Spouse
|
+-----------+----------------+------+------------+--------------+
7 rows in set (0.00 sec)

You might also like