SQL
SQL
SQL
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Database changed
+----------------------+
| Tables_in_student_db |
+----------------------+
| book |
| census |
| lolol |
| student |
| student_info |
+----------------------+
mysql> create table marks(Roll_No int primary key, Name varchar(33), Narks int);
+---------+----------------------+---------+------------+------+
+---------+----------------------+---------+------------+------+
+---------+----------------------+---------+------------+------+
+------------+-------------+------+-----+---------+-------+
+------------+-------------+------+-----+---------+-------+
+------------+-------------+------+-----+---------+-------+
-> ;
ERROR 4028 (HY000): A table must have at least one visible column.
mysql> CREATE TABLE BOOK_INFO(BOOK_ID varchar(10) primary key, BOOK_NAME varchar, Roll_No
int, foriegn key Roll_No references marks(Roll_No));
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 ', Roll_No int, foriegn key Roll_No
references marks(Roll_No))' at line 1
mysql> ;
ERROR:
No query specified
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 'key (Roll_No) references
marks(Roll_No))' at line 1
-> ;
+---------+-------------+-------+
+---------+-------------+-------+
| 1 | Yash Tandon | 96 |
| 2 | Rahul | 45 |
+---------+-------------+-------+
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`student_db`.`book_info`, CONSTRAINT `book_info_ibfk_1` FOREIGN KEY (`Roll_No`) REFERENCES
`marks` (`Roll_No`))
+---------+-------------+-------+
+---------+-------------+-------+
| 1 | Yash Tandon | 96 |
| 2 | Rahul | 45 |
+---------+-------------+-------+
+---------+---------------+---------+
+---------+---------------+---------+
+---------+---------------+---------+
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 'delect from from marks where
Roll_no="12"' 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 'from marks where Roll_no="12"' 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 'from marks where Roll_no=1' 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 'from marks where Roll_no="1"' at line 1
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails
(`student_db`.`book_info`, CONSTRAINT `book_info_ibfk_1` FOREIGN KEY (`Roll_No`) REFERENCES
`marks` (`Roll_No`))
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
+---------+---------------+---------+
+---------+---------------+---------+
+---------+---------------+---------+
+---------+-------+-------+
+---------+-------+-------+
| 2 | Rahul | 45 |
+---------+-------+-------+
+----------------------+
| Tables_in_student_db |
+----------------------+
| book |
| book_info |
| census |
| lolol |
| marks |
| student |
| student_info |
+----------------------+
7 rows in set (0.00 sec)
+---------+-------------+-------+
+---------+-------------+-------+
| 1 | Yash Tandon | 10 |
| 2 | Rahul | 10 |
| 3 | Gal | 10 |
| 4 | Rishi | 10 |
| 5 | Ria | 10 |
| 6 | Tanya | 10 |
| 7 | Archit | 10 |
| 8 | 1000 | 10 |
| 9 | 200czx | 10 |
| 10 | 300czx | 10 |
| 11 | 3000 | 10 |
| 13 | 0 | 10 |
| 14 | yash | 10 |
| 15 | NULL | 10 |
| 16 | Luffy | 10 |
| 17 | Tanjiro | 10 |
| 18 | Naruto | 10 |
| 19 | lolol | 10 |
+---------+-------------+-------+
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 'databses' at line 1
| Database |
+--------------------+
| employee |
| information_schema |
| mysql |
| performance_schema |
| sakila |
| student |
| student_db |
| sys |
| world |
+--------------------+
Database changed
+--------------------+
| Tables_in_employee |
+--------------------+
| emp |
| emp1 |
| emp2 |
| emp3 |
| emp4 |
| product |
+--------------------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+
+-------+-------+
| Pcode | Price |
+-------+-------+
| 101 | 250 |
| 101 | 5000 |
+-------+-------+
-> ;
+---------------+
| count(Gender) |
+---------------+
| 3|
+---------------+
1 row in set (0.00 sec)
-> ;
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 ') from emp' at line 1
+------------------------+
| count(distinct Gender) |
+------------------------+
| 2|
+------------------------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+
+---------------+
| count(Gender) |
+---------------+
| 2|
| 1|
+---------------+
+--------+---------------+
| Gender | count(Gender) |
+--------+---------------+
|M | 2|
|F | 1|
+--------+---------------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+--------+---------------+
| Gender | count(Gender) |
+--------+---------------+
|M | 3|
|F | 3|
+--------+---------------+
+---------+----------------+
| Dept_No | count(Dept_No) |
+---------+----------------+
| 10 | 4|
| 12 | 1|
| 11 | 1|
+---------+----------------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+---------+----------------+------------+
+---------+----------------+------------+
| 10 | 4| 25022 |
| 12 | 1| 2839 |
| 11 | 1| 282 |
+---------+----------------+------------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
mysql> 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 's' at line 1
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
-> ;
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
| Ecode | Ename | Gender | Grade | Gross | Dept_No |
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
+--------------+
| count(Grade) |
+--------------+
| 3|
| 2|
| 1|
+--------------+
+-------+--------------+
| Grade | count(Grade) |
+-------+--------------+
|A | 3|
|B | 2|
|C | 1|
+-------+--------------+
mysql> select Grade, count(Grade), Dept_No from emp GROUP BY Grade having Dept_No=10;
+-------+--------------+---------+
+-------+--------------+---------+
|A | 3| 10 |
|B | 2| 10 |
+-------+--------------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
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 'max(Gross) from emp' at line 1
+------------+
| max(Gross) |
+------------+
| 20000 |
+------------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+----------+
| count(*) |
+----------+
| 6|
+----------+
+--------------+
| count(Grade) |
+--------------+
| 6|
+--------------+
+-----------------------+
| count(distinct Grade) |
+-----------------------+
| 3|
+-----------------------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+-------+-------+--------+-------+-------+---------+
+------------+
| AVG(Gross) |
+------------+
| 4690.5000 |
+------------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
-> ;
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
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 '(Dept_No NOT NULL)' 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 '(Dept_No,NOT NULL)' at line 1
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
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 '(Dept_No,NOT NULL)' 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 '(Dept_No,NOT NULL)' at line 1
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
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 '(Dept_No NOT NULL)' 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 '(Gender char(1))' 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 '(Gender varchar(2))' at line 1
mysql> alter table emp add constraint EN_NOTNULL (Dept_No NOT NULL);
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 '(Dept_No NOT NULL)' at line 1
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+-------+--------+--------+-------+-------+---------+
+---------------+
| Gross+Dept_No |
+---------------+
| 5010 |
| 20012 |
| 2851 |
| 293 |
| 2832 |
+---------------+
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 'databses' at line 1
+--------------------+
| Database |
+--------------------+
| employee |
| information_schema |
| mysql |
| performance_schema |
| sakila |
| student |
| student_db |
| sys |
| world |
+--------------------+
Database changed
+----------------------+
| Tables_in_student_db |
+----------------------+
| book |
| book_info |
| census |
| lolol |
| marks |
| student |
| student_info |
+----------------------+
+---------+-------+-------+
+---------+-------+-------+
| 2 | Rahul | 45 |
+---------+-------+-------+
+-----+-------+---------+-------------+------+-------------+
+-----+-------+---------+-------------+------+-------------+
+-----+-------+---------+-------------+------+-------------+
+---------+-------------+-------+
+---------+-------------+-------+
| 1 | Yash Tandon | 10 |
| 2 | Rahul | 10 |
| 3 | Gal | 10 |
| 4 | Rishi | 10 |
| 5 | Ria | 10 |
| 6 | Tanya | 10 |
| 7 | Archit | 10 |
| 8 | 1000 | 10 |
| 9 | 200czx | 10 |
| 10 | 300czx | 10 |
| 11 | 3000 | 10 |
| 13 | 0 | 10 |
| 14 | yash | 10 |
| 15 | NULL | 10 |
| 16 | Luffy | 10 |
| 17 | Tanjiro | 10 |
| 18 | Naruto | 10 |
| 19 | lolol | 10 |
+---------+-------------+-------+
+----------------------+
| Tables_in_student_db |
+----------------------+
| book |
| book_info |
| census |
| lolol |
| marks |
| student |
| student_info |
+----------------------+
-> ;
+-----------------+------------+------------+---------+
+-----------------+------------+------------+---------+
+-----------------+------------+------------+---------+
-> ;
+---------+------+
| Roll_No | Name |
+---------+------+
| 1 | Yash |
+---------+------+
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 'BOOK_INFO' at line 1
+---------+---------------+---------+
+---------+---------------+---------+
+---------+---------------+---------+
+---------+----------------------+---------+------------+------+
+---------+----------------------+---------+------------+------+
-> ;
+---------+-------+-------+
+---------+-------+-------+
| 2 | Rahul | 45 |
+---------+-------+-------+
-> ;
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
-> ;
+-----------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+---------+---------------+---------+
+---------+---------------+---------+
+---------+---------------+---------+
'> ;
'> ;
'> ;
'> ;
'> ;)
'> \C
'> ):
'>