You are on page 1of 3

cclub@ubuntu:~$ mysql -u root -p

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.0.83-0ubuntu3 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database company;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| company
|
| company1
|
| employee
|
| harbour
|
| mysql
|
+--------------------+
6 rows in set (0.01 sec)
mysql> use company;
Database changed
mysql> create table employee
-> (fname varchar(20),
-> minit varchar(20),
-> lname varchar(20),
-> ssn int(9),
-> sex char(2),
-> salary float,
-> superssn int(9),
-> dno int(3)
-> )
-> ;
Query OK, 0 rows affected (0.09 sec)
mysql> create table department
-> (dname varchar(20),
-> dnumber int(3),
-> mgrssn int(9
-> ),
-> );
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 6
mysql> create table department (dname varchar(20), dnumber int(3), mgrssn int(9
) );
Query OK, 0 rows affected (0.00 sec)
mysql> create table dept_locations(dnumber int(3),dlocation varchar(30));
Query OK, 0 rows affected (0.00 sec)
mysql> create table project(pname varchar(2),pnumber int(3),plocation varchar(30
),dnum int(3));
Query OK, 0 rows affected (0.00 sec)
mysql> create table workson(essn int(9),pno int(3),hours int (2));

Query OK, 0 rows affected (0.00 sec)


mysql> create table dependent(essn int(9),dependent_name varchar(20),sex char(2)
,relationship varchar(20));
Query OK, 0 rows affected (0.00 sec)
mysql> insert into employee values('mary','k','john',123456789,f,30000,345621721
,3);
ERROR 1054 (42S22): Unknown column 'f' in 'field list'
mysql> insert into employee values('mary','k','john',123456789,'f',30000,3456217
21,3);
Query OK, 1 row affected (0.02 sec)
mysql> insert into employee values('anna','mary','kurian',123546798,'f',35000,12
3456789,1);
Query OK, 1 row affected (0.00 sec)
mysql> insert into employee values('john','b','smith',345621721,'m',30000,123456
789,2);
Query OK, 1 row affected (0.00 sec)
mysql> select *from employee;
+-------+-------+--------+-----------+------+--------+-----------+------+
| fname | minit | lname | ssn
| sex | salary | superssn | dno |
+-------+-------+--------+-----------+------+--------+-----------+------+
| mary | k
| john | 123456789 | f
| 30000 | 345621721 |
3 |
| anna | mary | kurian | 123546798 | f
| 35000 | 123456789 |
1 |
| john | b
| smith | 345621721 | m
| 30000 | 123456789 |
2 |
+-------+-------+--------+-----------+------+--------+-----------+------+
3 rows in set (0.00 sec)
mysql> select fname
-> from employee
-> where ssn=123456789;
+-------+
| fname |
+-------+
| mary |
+-------+
1 row in set (0.02 sec)
mysql> select *
-> from employee
-> where dno=2;
+-------+-------+-------+-----------+------+--------+-----------+------+
| fname | minit | lname | ssn
| sex | salary | superssn | dno |
+-------+-------+-------+-----------+------+--------+-----------+------+
| john | b
| smith | 345621721 | m
| 30000 | 123456789 |
2 |
+-------+-------+-------+-----------+------+--------+-----------+------+
1 row in set (0.00 sec)
mysql> select *
-> from employee
-> order by fname;
+-------+-------+--------+-----------+------+--------+-----------+------+
| fname | minit | lname | ssn
| sex | salary | superssn | dno |
+-------+-------+--------+-----------+------+--------+-----------+------+
| anna | mary | kurian | 123546798 | f
| 35000 | 123456789 |
1 |
| john | b
| smith | 345621721 | m
| 30000 | 123456789 |
2 |
| mary | k
| john | 123456789 | f
| 30000 | 345621721 |
3 |

+-------+-------+--------+-----------+------+--------+-----------+------+
3 rows in set (0.03 sec)
mysql> exit
Bye
cclub@ubuntu:~$

You might also like