0% found this document useful (0 votes)
6 views

SQL

Uploaded by

avijitmaji501
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SQL

Uploaded by

avijitmaji501
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Enter password: *******

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 9
Server version: 8.0.35 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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 tables;


ERROR 1046 (3D000): No database selected
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| navodaya |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.14 sec)

mysql> use navodaya;


Database changed
mysql> show tables
-> ;
+--------------------+
| Tables_in_navodaya |
+--------------------+
| class12 |
+--------------------+
1 row in set (0.05 sec)

mysql> desc class12;


+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| roll | int | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| age | int | YES | | NULL | |
| marks | float(5,2) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.03 sec)

mysql> alter table class12 modify (roll int);


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
int)' at line 1
mysql> alter table class12 modify roll int;
Query OK, 0 rows affected (0.35 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc class12;


+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| roll | int | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| age | int | YES | | NULL | |
| marks | float(5,2) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> create table class12(roll int,name varchar,subject varchar,age


int,percentage float);
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 ',subject
varchar,age int,percentage float)' at line 1
mysql> create table class12(roll int,name varchar(25),subject varchar(15),age
int,percentage float(5,2));
ERROR 1050 (42S01): Table 'class12' already exists
mysql> create table class11(roll int,name varchar(25),subject varchar(15),age
int,percentage float(5,2));
Query OK, 0 rows affected, 1 warning (0.46 sec)

mysql> insert values(1,'souvik','biology',18,85.3);


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(1,'souvik','biology',18,85.3)' at line 1
mysql> insert into class11 values(1,'souvik','biology',18,85.3);
Query OK, 1 row affected (0.09 sec)

mysql> insert into class11 values(2,'avijit','math',19,90.4);


Query OK, 1 row affected (0.11 sec)

mysql> show class11


-> ;
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 'class11'
at line 1
mysql> show table class11
-> ;
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 'class11'
at line 1
mysql> slecte * from class11;
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 'slecte *
from class11' at line 1
mysql> slect * from class11;
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 'slect *
from class11' at line 1
mysql> select * from class11;
+------+--------+---------+------+------------+
| roll | name | subject | age | percentage |
+------+--------+---------+------+------------+
| 1 | souvik | biology | 18 | 85.30 |
| 2 | avijit | math | 19 | 90.40 |
+------+--------+---------+------+------------+
2 rows in set (0.00 sec)
mysql> add primary key(roll);
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 'add
primary key(roll)' at line 1
mysql> alter table class11 add primary key(roll);
Query OK, 0 rows affected (1.42 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select * from class11;


+------+--------+---------+------+------------+
| roll | name | subject | age | percentage |
+------+--------+---------+------+------------+
| 1 | souvik | biology | 18 | 85.30 |
| 2 | avijit | math | 19 | 90.40 |
+------+--------+---------+------+------------+
2 rows in set (0.00 sec)

mysql> desc class11;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| roll | int | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| subject | varchar(15) | YES | | NULL | |
| age | int | YES | | NULL | |
| percentage | float(5,2) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> alter table class11 modify (age varchar(08));


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 '(age
varchar(08))' at line 1
mysql> alter table class11 modify (age number(8));
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 '(age
number(8))' at line 1
mysql> truncate class11;
Query OK, 0 rows affected (0.54 sec)

mysql> select * from class11;


Empty set (0.00 sec)

mysql> alter table class11 modify (age varchar(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 '(age
varchar(10))' at line 1
mysql> alter table class11 change (age varchar(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 '(age
varchar(10))' at line 1
mysql> alter table class11 change age age varchar(10);
Query OK, 0 rows affected (1.83 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc class11


-> ;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| roll | int | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| subject | varchar(15) | YES | | NULL | |
| age | varchar(10) | YES | | NULL | |
| percentage | float(5,2) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> alter table class11 change age dob varchar(10);


Query OK, 0 rows affected (0.47 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc class11


-> ;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| roll | int | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| subject | varchar(15) | YES | | NULL | |
| dob | varchar(10) | YES | | NULL | |
| percentage | float(5,2) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> insert into class11 values


-> (1,'avijit','math','15/06/2005',98.2);
Query OK, 1 row affected (0.07 sec)

mysql> select * from class11;


+------+--------+---------+------------+------------+
| roll | name | subject | dob | percentage |
+------+--------+---------+------------+------------+
| 1 | avijit | math | 15/06/2005 | 98.20 |
+------+--------+---------+------------+------------+
1 row in set (0.00 sec)

mysql> select * from class11;


+------+--------+---------+------------+------------+
| roll | name | subject | dob | percentage |
+------+--------+---------+------------+------------+
| 1 | avijit | math | 15/06/2005 | 98.20 |
+------+--------+---------+------------+------------+
1 row in set (0.00 sec)

mysql> insert into class11 values(mishba,science,22/22/2222,89.76);


ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into class11 values(2,mishba,science,22/22/2222,89.76);
ERROR 1054 (42S22): Unknown column 'mishba' in 'field list'
mysql> select * from class11;
+------+--------+---------+------------+------------+
| roll | name | subject | dob | percentage |
+------+--------+---------+------------+------------+
| 1 | avijit | math | 15/06/2005 | 98.20 |
+------+--------+---------+------------+------------+
1 row in set (0.00 sec)

mysql> insert into class11 values(2,'mishba','science',22/22/2222,89.76);


ERROR 1406 (22001): Data too long for column 'dob' at row 1
mysql> insert into class11 values(2,'mishba','science',22/12/2222,89.76);
ERROR 1406 (22001): Data too long for column 'dob' at row 1
mysql> insert into class11 values(2,'mishba','science',22/12/2022,89.76);
ERROR 1406 (22001): Data too long for column 'dob' at row 1
mysql> insert into class11 values(2,'mishba','science','22/12/2022',89.76);
Query OK, 1 row affected (0.07 sec)

mysql> select * from class11;


+------+--------+---------+------------+------------+
| roll | name | subject | dob | percentage |
+------+--------+---------+------------+------------+
| 1 | avijit | math | 15/06/2005 | 98.20 |
| 2 | mishba | science | 22/12/2022 | 89.76 |
+------+--------+---------+------------+------------+
2 rows in set (0.00 sec)

mysql> qfdghgqfvegshu
-> ;
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
'qfdghgqfvegshu' at line 1
mysql> select * from class11;
+------+--------+---------+------------+------------+
| roll | name | subject | dob | percentage |
+------+--------+---------+------------+------------+
| 1 | avijit | math | 15/06/2005 | 98.20 |
| 2 | mishba | science | 22/12/2022 | 89.76 |
+------+--------+---------+------------+------------+
2 rows in set (0.00 sec)

You might also like