Download as TXT, PDF, TXT or read online from Scribd
Download as txt, pdf, or txt
You are on page 1of 5
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 Server version: 8.0.38 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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 databases;
+--------------------+ | Database | +--------------------+ | class | | college | | hotel | | information_schema | | model | | mysql | | performance_schema | | r_company | | sys | | t_shop | | visiotech | +--------------------+ 11 rows in set (0.01 sec)
mysql> creat database employ;
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 database employ' at line 1 mysql> create database employ; Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+ | Database | +--------------------+ | class | | college | | employ | | hotel | | information_schema | | model | | mysql | | performance_schema | | r_company | | sys | | t_shop | | visiotech | +--------------------+ 12 rows in set (0.00 sec)
mysql> use employ;
Database changed mysql> creat table emp_details(id int,name varchar(10),salary int,dob date); 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 table emp_details(id int,name varchar(10),salary int,dob date)' at line 1 mysql> creat table emp_details(id int,name varchar(10),division varchar(5),dob date); 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 table emp_details(id int,name varchar(10),division varchar(5),dob date)' at line 1 mysql> creat table emp_detail(id int,name varchar(10),division varchar(5),dob date); 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 table emp_detail(id int,name varchar(10),division varchar(5),dob date)' at line 1 mysql> create table emp_details(id int,name varchar(10),division varchar(5),dob date); Query OK, 0 rows affected (0.03 sec)
mysql> desc emp_details;
+----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | id | int | YES | | NULL | | | name | varchar(10) | YES | | NULL | | | division | varchar(5) | YES | | NULL | | | dob | date | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec)
mysql> alter table emp_details modify email varchar(20);
+----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | id | int | YES | | NULL | | | name | varchar(10) | YES | | NULL | | | division | varchar(5) | YES | | NULL | | | dob | date | YES | | NULL | | | email | varchar(20) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)
mysql> alter table emp_details rename column name id to rollno;
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 'id to rollno' at line 1 mysql> alter table emp_details rename column id to rollno; Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> desc emp_details;
+----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | rollno | int | YES | | NULL | | | name | varchar(10) | YES | | NULL | | | division | varchar(5) | YES | | NULL | | | dob | date | YES | | NULL | | | email | varchar(20) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)
mysql> alter table emp_details drop column division;
+--------+---------+------------+ | rollno | name | dob | +--------+---------+------------+ | 101 | vinayak | 2001-02-23 | | 102 | Raj | 2002-06-15 | | 103 | Ram | 2002-06-16 | +--------+---------+------------+ 3 rows in set (0.00 sec)
mysql> select * from emp_details order by desc;
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 'desc' at line 1 mysql> select * from emp_details group by name; ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employ.emp_details.rollno' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql> mysql> select * from emp_details group by vinayak; ERROR 1054 (42S22): Unknown column 'vinayak' in 'group statement' mysql> select * from emp_details group by dob; ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employ.emp_details.rollno' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql> select rollno,name from emp_details; +--------+---------+ | rollno | name | +--------+---------+ | 101 | vinayak | | 102 | Raj | | 103 | Ram | +--------+---------+ 3 rows in set (0.00 sec)
mysql> select rollno,dob from emp_details;
+--------+------------+ | rollno | dob | +--------+------------+ | 101 | 2001-02-23 | | 102 | 2002-06-15 | | 103 | 2002-06-16 | +--------+------------+ 3 rows in set (0.00 sec)
mysql> truncate table emp_details;
Query OK, 0 rows affected (0.03 sec)
mysql> desc emp_details;
+--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | rollno | int | YES | | NULL | | | name | varchar(15) | YES | | NULL | | | dob | date | YES | | NULL | | +--------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)