0% found this document useful (0 votes)
14 views3 pages

Mysql Assn1

Uploaded by

Tushar Bhosale
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)
14 views3 pages

Mysql Assn1

Uploaded by

Tushar Bhosale
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/ 3

mysql> create table SALESPEOPLE

-> (Snum int(4), Sname varchar(10), City varchar(10), Comm float(3,2));


Query OK, 0 rows affected, 2 warnings (0.02 sec)

mysql> create table CUSTOMERS


-> (Cnum int (4), Cname varchar(10), City varchar(10), Rating int(4), Snum
int(4));
Query OK, 0 rows affected, 3 warnings (0.01 sec)

mysql> create table ORDERS


-> (Onum int(4), Amt float(7,2), Odate date, Cnum int(4), Snum int(4));
Query OK, 0 rows affected, 4 warnings (0.02 sec)

mysql> insert into SALESPEOPLE


-> values('1001','Peel','London','.12'),
-> ('1002','Serres','San Jose','.13'),
-> ('1004','Motika','London','.11'),
-> ('1007','Rifkin','Barcelona','.15'),
-> ('1003','Axelrod','New York','.10');
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0

mysql> select * from SALESPEOPLE


-> ;
+------+---------+-----------+------+
| Snum | Sname | City | Comm |
+------+---------+-----------+------+
| 1001 | Peel | London | 0.12 |
| 1002 | Serres | San Jose | 0.13 |
| 1004 | Motika | London | 0.11 |
| 1007 | Rifkin | Barcelona | 0.15 |
| 1003 | Axelrod | New York | 0.10 |
+------+---------+-----------+------+
5 rows in set (0.00 sec)

mysql> insert into customers


-> values(2001,'Hoffman','London','100',1001),
-> (2002,'Giovanni','Rome','200',1003),
-> (2003,'Liu','San Jose','200',1002),
-> (2004,'Grass','Berlin','300',1002),
-> (2006,'Clemens','London','100',1001),
-> (2008,'Cisneros','San Jose','300',1007),
-> (2007,'Pereira','Rome','100',1004);
Query OK, 7 rows affected (0.01 sec)
Records: 7 Duplicates: 0 Warnings: 0

mysql> insert into orders


-> values(3001,18.69,'03-OCT-1990',2008,1007),
-> (3003,767.19,'03-OCT-1990',2001,1001),
-> (3002,1900.10,'03-OCT-1990',2007,1004),
-> (3005,5160.45,'03-OCT-1990',2003,1002),
-> (3006,1098.16,'03- OCT -1990',2008,1007),
-> 3009 1713.23 04- OCT -1990 2002 1003
-> 3007 75.75 04- OCT -1990 2004 1002
-> 3008 4723.00 05- OCT -1990 2006 1001
-> 3010 1309.95 06- OCT -1990 2004 1002
-> ^X
-> ;
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 '3009
1713.23 04- OCT -1990 2002 1003
3007 75.75 04- OCT -1990 2004 1002
3008 4' at line 7
mysql> select * from orders
-> ;
Empty set (0.00 sec)

mysql> insert into orders


-> -> values(3001,18.69,'03-OCT-1990',2008,1007),
-> -> (3003,767.19,'03-OCT-1990',2001,1001),
-> -> (3002,1900.10,'03-OCT-1990',2007,1004),
-> -> (3005,5160.45,'03-OCT-1990',2003,1002),
-> ;(3006,1098.16,'03- OCT -1990',2008,1007),
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 '->
values(3001,18.69,'03-OCT-1990',2008,1007),
-> (3003,767.19,'03-OCT-1990'' at line 2
-> ;
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
'3006,1098.16,'03- OCT -1990',2008,1007),' at line 1
mysql> select * from orders;
Empty set (0.00 sec)

mysql> insert into orders


-> values(3001,18.69,'03-OCT-1990',2008,1007),
-> (3003,767.19,'03-OCT-1990',2001,1001),
-> (3002,1900.10,'03-OCT-1990',2007,1004),
-> (3005,5160.45,'03-OCT-1990',2003,1002),
-> (3006,1098.16,'03-OCT-1990',2008,1007),
-> (3009,1713.23,'04-OCT-1990',2002,1003),
-> (3007,75.75,'04-OCT-1990',2004,1002),
-> (3008,4723.00,'05-OCT-1990',2006,1001),
-> (3010,1309.95,'06-OCT-1990',2004,1002),
-> (3011,9891.88,'06-OCT-1990',2006,1001);
ERROR 1292 (22007): Incorrect date value: '03-OCT-1990' for column 'Odate' at row 1
mysql> INSERT INTO orders
-> VALUES
-> (3001, 18.69, STR_TO_DATE('03-OCT-1990', '%d-%b-%Y'), 2008, 1007),
-> (3003, 767.19, STR_TO_DATE('03-OCT-1990', '%d-%b-%Y'), 2001, 1001),
-> (3002, 1900.10, STR_TO_DATE('03-OCT-1990', '%d-%b-%Y'), 2007, 1004),
-> (3005, 5160.45, STR_TO_DATE('03-OCT-1990', '%d-%b-%Y'), 2003, 1002),
-> (3006, 1098.16, STR_TO_DATE('03-OCT-1990', '%d-%b-%Y'), 2008, 1007),
-> (3009, 1713.23, STR_TO_DATE('04-OCT-1990', '%d-%b-%Y'), 2002, 1003),
-> (3007, 75.75, STR_TO_DATE('04-OCT-1990', '%d-%b-%Y'), 2004, 1002),
-> (3008, 4723.00, STR_TO_DATE('05-OCT-1990', '%d-%b-%Y'), 2006, 1001),
-> (3010, 1309.95, STR_TO_DATE('06-OCT-1990', '%d-%b-%Y'), 2004, 1002),
-> (3011, 9891.88, STR_TO_DATE('06-OCT-1990', '%d-%b-%Y'), 2006, 1001);
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> select * from orders;


+------+---------+------------+------+------+
| Onum | Amt | Odate | Cnum | Snum |
+------+---------+------------+------+------+
| 3001 | 18.69 | 1990-10-03 | 2008 | 1007 |
| 3003 | 767.19 | 1990-10-03 | 2001 | 1001 |
| 3002 | 1900.10 | 1990-10-03 | 2007 | 1004 |
| 3005 | 5160.45 | 1990-10-03 | 2003 | 1002 |
| 3006 | 1098.16 | 1990-10-03 | 2008 | 1007 |
| 3009 | 1713.23 | 1990-10-04 | 2002 | 1003 |
| 3007 | 75.75 | 1990-10-04 | 2004 | 1002 |
| 3008 | 4723.00 | 1990-10-05 | 2006 | 1001 |
| 3010 | 1309.95 | 1990-10-06 | 2004 | 1002 |
| 3011 | 9891.88 | 1990-10-06 | 2006 | 1001 |
+------+---------+------------+------+------+
10 rows in set (0.00 sec)

mysql> SHOW KEYS FROM CUSTOMERS WHERE Key_name = 'PRIMARY';


Empty set (0.01 sec)

mysql> select * from customers;


+------+----------+----------+--------+------+
| Cnum | Cname | City | Rating | Snum |
+------+----------+----------+--------+------+
| 2001 | Hoffman | London | 100 | 1001 |
| 2002 | Giovanni | Rome | 200 | 1003 |
| 2003 | Liu | San Jose | 200 | 1002 |
| 2004 | Grass | Berlin | 300 | 1002 |
| 2006 | Clemens | London | 100 | 1001 |
| 2008 | Cisneros | San Jose | 300 | 1007 |
| 2007 | Pereira | Rome | 100 | 1004 |
+------+----------+----------+--------+------+
7 rows in set (0.00 sec)

You might also like