sql
sql
mysql> CREATE TABLE Project(Pj_id int, Pj_name varchar(255), Pj_duration varchar(255),Pj_dept varchar(255),Pj_d_id int);
Query OK, 0 rows affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)_name,Pj_duration,Pj_dept,Pj_d_id)values(115,'EXPANSION','LONGTERM','PRODUCTION AND FINANCE',1115 AND 1118);
mysql> INSERT INTO Project(pj_id,Pj_name,Pj_duration,Pj_dept,Pj_d_id)values(115,'EXPANSION','LONGTERM','PRODUCTION AND FINANCE',1115 AND 1118);
Query OK, 1 row affected (0.00 sec)
ERROR:
No query specified
mysql> CREATE table Persons(P_id int, Lname varchar(255), Fname varchar(255),Address va;
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 'va' at line 1
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(1,'dahiya','astha','ablock',20000,'sonipat',1111,111);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(2,'malik','riya','bblock',20030,'Sirsa',1112,112);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(3,'Sharma','Diya','cblock',30030,'Pnaipat',1113,113);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(4,'Smith','john','dblock',267430,'Karnal',1114,114);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(5,'Jack','Mathews','eblock',21430,'Houston',1115,115);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(6,'Jones','chris','fblock',1110,'Manhattan',1116,116);
ERROR 3819 (HY000): Check constraint 'persons_chk_2' is violated.
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(6,'Jones','chris','fblock',1110,'Manhattan',1116,111);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(7,'Garcia','jessica','gblock',133310,'New york',1117,112);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(8,'Akhsit','jessica;ca','gblock',133310,'New york',1117,112);ry ,City ,D_id ,Pj_id )vaQuery OK, 1 row affected (
0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(8,'Akhsit','Rathee','hblock',1310,'Churu',1118,113);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(9,'Neelam','sangwan','iblock',1222310,'Ambala',1119,114);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(10,'Anil','Dahiya','jblock',134222310,'Chandigarh',1111,115);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(11,'kunal','rana','kblock',34222310,'jhajhar',1112,111);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune',1113,112);
'> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune';,1113,112);
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 'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , F' at line 1
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 ',1113,112)' at line 1
mysql> select * from Persons;
+------+--------+---------+---------+-----------+------------+------+-------+
| P_id | Lname | Fname | Address | Salary | City | D_id | Pj_id |
+------+--------+---------+---------+-----------+------------+------+-------+
| 1 | dahiya | astha | ablock | 20000 | sonipat | 1111 | 111 |
| 2 | malik | riya | bblock | 20030 | Sirsa | 1112 | 112 |
| 3 | Sharma | Diya | cblock | 30030 | Pnaipat | 1113 | 113 |
| 4 | Smith | john | dblock | 267430 | Karnal | 1114 | 114 |
| 5 | Jack | Mathews | eblock | 21430 | Houston | 1115 | 115 |
| 6 | Jones | chris | fblock | 1110 | Manhattan | 1116 | 111 |
| 7 | Garcia | jessica | gblock | 133310 | New york | 1117 | 112 |
| 8 | Akhsit | Rathee | hblock | 1310 | Churu | 1118 | 113 |
| 9 | Neelam | sangwan | iblock | 1222310 | Ambala | 1119 | 114 |
| 10 | Anil | Dahiya | jblock | 134222310 | Chandigarh | 1111 | 115 |
| 11 | kunal | rana | kblock | 34222310 | jhajhar | 1112 | 111 |
+------+--------+---------+---------+-----------+------------+------+-------+
11 rows in set (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev','singh','lblock',342312310,'pune'1114,113);
'>
'> ;
'> ;;;
'> sff;
'> sssfdn;
'>
'>
'>
'>
'> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev','singh','lblock',342312310,'pune'1114,113);
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 'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , F' at line 1
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 '1114,113)' at line 1
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev','singh','lblock',342312310,'pune'1114,113);
;
;;;
sff;
sssfdn;
INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev','singh','lblock',342312310,'pune',1113,112);
'> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev,'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(12,'dev','singh','lblock',342312310,'pune'1114,113);
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 'singh','lblock',342312310,'pune',1113,112);
INSERT INTO Persons(P_id , Lname , F' at line 1
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 '1114,113)' at line 1
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(11,'dev','pratap','lblock',342310,'hyderabad',1113,112);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(11,'chirag','sehgal','mblock',34874382310,'bihar',1114,113);
ERROR 1264 (22003): Out of range value for column 'Salary' at row 1
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(11,'chirag','sehgal','mblock',3480,'bihar',1114,113);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(13,'SHAURYA','dahiya','nblock',32310,'patna',1115,114);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL servmysql> UPDATE Persons SET P_id=12 w;
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 'w' at line 1
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(14,'Sambhav','Godara','mblock',312310,'dehradun',1116,115);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(16,'ASHI','Chikkara','oblock',37777,'auli',1117,111);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(17,'Alia','mehta','pblock',377,'delhi',1118,112);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(18,'rohan','singh','qblock',1177,'noida',1119,113);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(19,'lakshay','goyal','rblock',2177,'samalkha',1111,114);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Persons(P_id , Lname , Fname ,Address ,Salary ,City ,D_id ,Pj_id )values(20,'jiya','girdhar','sblock',12177,'gurgaon',1112,115);
Query OK, 1 row affected (0.00 sec)
ERROR:
No query specified
mysql> ALTER TABLE Persons ADD Gender varchar(255) CHECK(Gender='male' ||Gender='female' || Gender='Others');
Query OK, 20 rows affected, 2 warnings (0.03 sec)
Records: 20 Duplicates: 0 Warnings: 2
mysql> ALTER TABLE Persons ADD Gender varchar(255) CHECK(Gender='male' ||Gender='female' || Gender='Others') AFTER Fname;
ERROR 1060 (42S21): Duplicate column name 'Gender'
mysql> ALTER TABLE Project DELETE Pj_duration;
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 'DELETE Pj_duration' at line 1
mysql> ALTER Project DELETE Pj_duration;
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 'Project DELETE Pj_duration' at line 1
mysql> ALTER Project DROP Pj_duration;
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 'Project DROP Pj_duration' at line 1
mysql> ALTER Project DELETE Pj_duration;
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 'Project DELETE Pj_duration' at line 1
mysql> ALTER TABLE Project DELETE Pj_duration;
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 'DELETE Pj_duration' at line 1
mysql> ALTER TABLE Project DELETE column Pj_duration;
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 'DELETE column Pj_duration' at line 1
mysql> ALTER TABLE Project DROP Pj_duration;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> SELECT * from Persons WHERE Lname LIKE NOT 'B' or 'S';
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 'NOT 'B' or 'S'' at line 1
mysql> SELECT * from Persons WHERE Lname NOT LIKE 'B' or 'S';
+------+---------+----------+---------+----------+-----------+------+-------+--------+
| P_id | Lname | Fname | Address | Salary | City | D_id | Pj_id | Gender |
+------+---------+----------+---------+----------+-----------+------+-------+--------+
| 1 | dahiya | astha | ablock | 20000 | sonipat | 1111 | 111 | female |
| 2 | malik | riya | bblock | 20030 | Sirsa | 1112 | 112 | female |
| 3 | Sharma | Diya | cblock | 30030 | Pnaipat | 1113 | 113 | male |
| 4 | Smith | john | dblock | 267430 | Karnal | 1114 | 114 | male |
| 5 | Jack | Mathews | eblock | 21430 | Houston | 1115 | 115 | female |
| 6 | Jones | chris | fblock | 1110 | Manhattan | 1116 | 111 | male |
| 7 | Garcia | jessica | gblock | 133310 | New york | 1117 | 112 | female |
| 8 | Akhsit | Rathee | hblock | 1310 | Churu | 1118 | 113 | Others |
| 9 | Neelam | sangwan | iblock | 1222310 | Ambala | 1119 | 114 | female |
| 11 | kunal | rana | kblock | 34222310 | jhajhar | 1112 | 111 | female |
| 12 | dev | pratap | lblock | 342310 | hyderabad | 1113 | 112 | Others |
| 13 | chirag | sehgal | mblock | 3480 | bihar | 1114 | 113 | female |
| 14 | SHAURYA | dahiya | nblock | 32310 | patna | 1115 | 114 | male |
| 15 | Sambhav | Godara | mblock | 312310 | dehradun | 1116 | 115 | female |
| 16 | ASHI | Chikkara | oblock | 37777 | auli | 1117 | 111 | male |
| 17 | Alia | mehta | pblock | 377 | delhi | 1118 | 112 | female |
| 18 | rohan | singh | qblock | 1177 | noida | 1119 | 113 | male |
| 19 | lakshay | goyal | rblock | 2177 | samalkha | 1111 | 114 | female |
| 20 | jiya | girdhar | sblock | 12177 | gurgaon | 1112 | 115 | Others |
+------+---------+----------+---------+----------+-----------+------+-------+--------+
19 rows in set, 1 warning (0.00 sec)
mysql> SELECT * from Persons WHERE Lname NOT LIKE 'B' or 'S' OR 'P';
+------+---------+----------+---------+----------+-----------+------+-------+--------+
| P_id | Lname | Fname | Address | Salary | City | D_id | Pj_id | Gender |
+------+---------+----------+---------+----------+-----------+------+-------+--------+
| 1 | dahiya | astha | ablock | 20000 | sonipat | 1111 | 111 | female |
| 2 | malik | riya | bblock | 20030 | Sirsa | 1112 | 112 | female |
| 3 | Sharma | Diya | cblock | 30030 | Pnaipat | 1113 | 113 | male |
| 4 | Smith | john | dblock | 267430 | Karnal | 1114 | 114 | male |
| 5 | Jack | Mathews | eblock | 21430 | Houston | 1115 | 115 | female |
| 6 | Jones | chris | fblock | 1110 | Manhattan | 1116 | 111 | male |
| 7 | Garcia | jessica | gblock | 133310 | New york | 1117 | 112 | female |
| 8 | Akhsit | Rathee | hblock | 1310 | Churu | 1118 | 113 | Others |
| 9 | Neelam | sangwan | iblock | 1222310 | Ambala | 1119 | 114 | female |
| 11 | kunal | rana | kblock | 34222310 | jhajhar | 1112 | 111 | female |
| 12 | dev | pratap | lblock | 342310 | hyderabad | 1113 | 112 | Others |
| 13 | chirag | sehgal | mblock | 3480 | bihar | 1114 | 113 | female |
| 14 | SHAURYA | dahiya | nblock | 32310 | patna | 1115 | 114 | male |
| 15 | Sambhav | Godara | mblock | 312310 | dehradun | 1116 | 115 | female |
| 16 | ASHI | Chikkara | oblock | 37777 | auli | 1117 | 111 | male |
| 17 | Alia | mehta | pblock | 377 | delhi | 1118 | 112 | female |
| 18 | rohan | singh | qblock | 1177 | noida | 1119 | 113 | male |
| 19 | lakshay | goyal | rblock | 2177 | samalkha | 1111 | 114 | female |
| 20 | jiya | girdhar | sblock | 12177 | gurgaon | 1112 | 115 | Others |
+------+---------+----------+---------+----------+-----------+------+-------+--------+
19 rows in set, 2 warnings (0.00 sec)
Database changed
mysql> SHOW TABLES;
+------------------+
| Tables_in_ib1 |
+------------------+
| College |
| employee |
| health |
| pg |
| product |
| products |
| samplesuperstore |
| student |
| study |
+------------------+
9 rows in set (0.01 sec)
Database changed
mysql> DROP April_Projects;
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 'April_Projects' at line 1
mysql> DROP table April_Projects;
ERROR 3730 (HY000): Cannot drop table 'april_projects' referenced by a foreign key constraint 'persons_ibfk_2' on table 'Persons'.
mysql> DROP table April_projects;
ERROR 3730 (HY000): Cannot drop table 'april_projects' referenced by a foreign key constraint 'persons_ibfk_2' on table 'Persons'.
mysql> DROP April_projects;
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 'April_projects' at line 1
mysql> DROP April_Projects;
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 'April_Projects' at line 1
mysql> DROP TABLE April_Projects;
ERROR 3730 (HY000): Cannot drop table 'april_projects' referenced by a foreign key constraint 'persons_ibfk_2' on table 'Persons'.
mysql> SELECT SUM(Salary) FROM Persons WHERE D_id=1111;
+-------------+
| SUM(Salary) |
+-------------+
| 22177 |
+-------------+
1 row in set (0.01 sec)
mysql> SELECT D_id ,SUM(Salary) FROM Persons GROUP BY D_id HAVING Salary>70000;
ERROR 1054 (42S22): Unknown column 'Salary' in 'having clause'
mysql> SELECT D_id ,SUM(Salary) FROM Persons GROUP BY D_id HAVING Salary GREATER THAN
70000;
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 'GREATER THAN 70000' at line 1
mysql> SELECT D_id ,SUM(Salary) FROM Persons GROUP BY D_id HAVING (Salar)y> 70000;
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 'y> 70000' at line 1
mysql> SELECT D_id ,SUM(Salary) FROM Persons GROUP BY D_id HAVING (Salary)> 70000;
ERROR 1054 (42S22): Unknown column 'Salary' in 'having clause'
mysql> SELECT D_id ,SUM(Salary) FROM Persons GROUP BY D_id HAVING SUM(Salary)> 70000;
+------+-------------+
| D_id | SUM(Salary) |
+------+-------------+
| 1112 | 34254517 |
| 1113 | 372340 |
| 1114 | 270910 |
| 1116 | 313420 |
| 1117 | 171087 |
| 1119 | 1223487 |
+------+-------------+
6 rows in set (0.00 sec)
mysql> CREATE TABLE Orders(O_id int, Orderdate DATE, Orderprice int ,Customer varchar(255));
Query OK, 0 rows affected (0.01 sec)
+---------------------+
| NOW() |
+---------------------+
| 2024-10-15 11:42:20 |
+---------------------+
1 row in set (0.10 sec)
mysql>