0% found this document useful (0 votes)
3 views10 pages

Dbms

The document details a MySQL session where a user creates a database and a table, performs various SQL operations including inserting, updating, and selecting data, and encounters multiple syntax errors. The user successfully creates an 'employee' table, inserts records, and updates values, but also faces challenges with incorrect SQL commands. Ultimately, the session demonstrates basic database management tasks while highlighting common mistakes in SQL syntax.

Uploaded by

aamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Dbms

The document details a MySQL session where a user creates a database and a table, performs various SQL operations including inserting, updating, and selecting data, and encounters multiple syntax errors. The user successfully creates an 'employee' table, inserts records, and updates values, but also faces challenges with incorrect SQL commands. Ultimately, the session demonstrates basic database management tasks while highlighting common mistakes in SQL syntax.

Uploaded by

aamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Enter password: ****

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

Your MySQL connection id is 19

Server version: 8.0.39 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> \h

For information about MySQL products and services, visit:

http://www.mysql.com/

For developer information, including the MySQL Reference Manual, visit:

http://dev.mysql.com/

To buy MySQL Enterprise support, training, or other products, visit:

https://shop.mysql.com/

List of all MySQL commands:

Note that all text commands must be first on line and end with ';'

? (\?) Synonym for `help'.


clear (\c) Clear the current input statement.

connect (\r) Reconnect to the server. Optional arguments are db and host.

delimiter (\d) Set statement delimiter.

ego (\G) Send command to mysql server, display result vertically.

exit (\q) Exit mysql. Same as quit.

go (\g) Send command to mysql server.

help (\h) Display this help.

notee (\t) Don't write into outfile.

print (\p) Print current command.

prompt (\R) Change your mysql prompt.

quit (\q) Quit mysql.

rehash (\#) Rebuild completion hash.

source (\.) Execute an SQL script file. Takes a file name as an argument.

status (\s) Get status information from the server.

system (\!) Execute a system shell command.

tee (\T) Set outfile [to_outfile]. Append everything into given outfile.

use (\u) Use another database. Takes database name as argument.

charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.

warnings (\W) Show warnings after every statement.

nowarning (\w) Don't show warnings after every statement.

resetconnection(\x) Clean session context.

query_attributes Sets string parameters (name1 value1 name2 value2 ...) for the next query to pick up.

ssl_session_data_print Serializes the current SSL session data to stdout or file

For server side help, type 'help contents'


mysql> create database employees;

Query OK, 1 row affected (0.07 sec)

mysql> use employees;

Database changed

mysql> create table employee;

ERROR 4028 (HY000): A table must have at least one visible column.

mysql> create table employee(empid int(20), ename varchar(50));

Query OK, 0 rows affected, 1 warning (0.31 sec)

mysql> insert into employee values (11,'suraj',12,'tejas');

ERROR 1136 (21S01): Column count doesn't match value count at row 1

mysql> insert into employee values (11,'suraj');

Query OK, 1 row affected (0.05 sec)

mysql> swelect * from employee;

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 'swelect * from employee' at line 1

mysql> select * from employee;

+-------+-------+

| empid | ename |

+-------+-------+

| 11 | suraj |

+-------+-------+

1 row in set (0.00 sec)


mysql> update employee

-> ;

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 '' at line 1

mysql> insert into employee values (11,'tejas');

Query OK, 1 row affected (0.05 sec)

mysql> select * from employee;

+-------+-------+

| empid | ename |

+-------+-------+

| 11 | suraj |

| 11 | tejas |

+-------+-------+

2 rows in set (0.00 sec)

mysql> update employee add column (esalary int(50));

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 column (esalary int(50))' at line 1

mysql> update employee add (esalary int(50));

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 (esalary int(50))' at line 1

mysql> update employee set

->

-> ;
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 '' at line 1

mysql> update employee

-> update employee;

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 'update employee' at line 2

mysql> alter table employee add (esalary int(50));

Query OK, 0 rows affected, 1 warning (0.33 sec)

Records: 0 Duplicates: 0 Warnings: 1

mysql> update employee

-> select * from employee;

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 'select * from employee' at line 2

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |

+-------+-------+---------+

| 11 | suraj | NULL |

| 11 | tejas | NULL |

+-------+-------+---------+

2 rows in set (0.00 sec)

mysql> update employee

-> set esalary=5000

-> set empid=12

-> where ename=tejas;


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 'set empid=12

where ename=tejas' at line 3

mysql> update employee

-> set empid=12

-> where ename='tejas';

Query OK, 1 row affected (0.08 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |

+-------+-------+---------+

| 11 | suraj | NULL |

| 12 | tejas | NULL |

+-------+-------+---------+

2 rows in set (0.00 sec)

mysql> update employee

-> set esalary=5000

-> where eid=11;

ERROR 1054 (42S22): Unknown column 'eid' in 'where clause'

mysql> update employee

-> set esalary=5000

-> where empid=12;

Query OK, 1 row affected (0.04 sec)


Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |

+-------+-------+---------+

| 11 | suraj | NULL |

| 12 | tejas | 5000 |

+-------+-------+---------+

2 rows in set (0.00 sec)

mysql> update employee

-> SELECT

-> product_name,

-> price,

-> CASE

-> WHEN price > 100 THEN 'Expensive'

-> ELSE 'Affordable'

-> END AS price_category

-> FROM

-> products;

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 'SELECT

product_name,

price,

CASE
WHEN price > 100 THEN 'Ex' at line 2

mysql> update employee

-> set esalary=7000

-> where empid=11;

Query OK, 1 row affected (0.05 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |

+-------+-------+---------+

| 11 | suraj | 7000 |

| 12 | tejas | 5000 |

+-------+-------+---------+

2 rows in set (0.00 sec)

mysql> truncate table employee;

Query OK, 0 rows affected (0.43 sec)

mysql> select * from employee;

Empty set (0.00 sec)

mysql> drop table employee;

Query OK, 0 rows affected (0.21 sec)


mysql> select * from employee;

ERROR 1146 (42S02): Table 'employees.employee' doesn't exist

mysql> createv table employee (empid int(20),ename varchar(50), esalary int(50));

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 'createv table employee (empid int(20),ename
varchar(50), esalary int(50))' at line 1

mysql> create table employee (empid int(20),ename varchar(50), esalary int(50));

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

mysql> insert into employee values (11,'suraj',5000);

Query OK, 1 row affected (0.04 sec)

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |

+-------+-------+---------+

| 11 | suraj | 5000 |

+-------+-------+---------+

1 row in set (0.00 sec)

mysql> insert into employee values (12,'tejas',7000);

Query OK, 1 row affected (0.04 sec)

mysql> select * from employee;

+-------+-------+---------+

| empid | ename | esalary |


+-------+-------+---------+

| 11 | suraj | 5000 |

| 12 | tejas | 7000 |

+-------+-------+---------+

2 rows in set (0.00 sec)

mysql> SELECT

-> product_name,

-> price,

-> CASE

-> WHEN price > 100 THEN 'Expensive'

-> ELSE 'Affordable'

-> END AS price_category

-> FROM

-> products;

ERROR 1146 (42S02): Table 'employees.products' doesn't exist

mysql>

You might also like