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

My SQL First Class

The document shows the steps to create a MySQL database called Batch7pm and a table called Employee within it. It inserts some sample records into the Employee table and runs some queries to view the data.

Uploaded by

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

My SQL First Class

The document shows the steps to create a MySQL database called Batch7pm and a table called Employee within it. It inserts some sample records into the Employee table and runs some queries to view the data.

Uploaded by

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

Enter password: ****

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


Your MySQL connection id is 10
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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> create database Batch7pm;


Query OK, 1 row affected (0.01 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| 9am |
| abc |
| akzo |
| alisha |
| amar |
| amitoj |
| amrendra |
| bankdb |
| batch10am |
| batch4pm |
| batch5pm |
| batch7pm |
| batch8pm |
| batch9am |
| bmw |
| cars24 |
| college |
| collegedata |
| collegeinfo |
| collegetca |
| company |
| computer |
| crud |
| db |
| dbcollege |
| dbemp |
| dell |
| hbntest |
| honda |
| information_schema |
| karan |
| kiran |
| loginapp |
| manipal |
| manoj |
| maruti |
| mbs |
| mobile |
| monu |
| mycollege |
| mycompany |
| mydb |
| myhiber |
| mysql |
| newindia |
| newindiacom |
| panindia |
| pankaj |
| paras |
| performance_schema |
| pqr |
| python_db |
| rbi |
| rbimbs |
| springbootcrud |
| sys |
| tca |
| tcanew |
| testing |
| training |
| usernew |
| viraj |
| xyz |
+--------------------+
63 rows in set (0.00 sec)

mysql> use batch7pm;


Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create database Neha;


Query OK, 1 row affected (0.01 sec)

mysql> use Neha;


Database changed
mysql> use batch7pm;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table Employee(empid int primary key,empname varchar(40),region


varchar(40),salary int, deptid int);
Query OK, 0 rows affected (0.08 sec)

mysql> desc employee;


+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| empid | int | NO | PRI | NULL | |
| empname | varchar(40) | YES | | NULL | |
| region | varchar(40) | YES | | NULL | |
| salary | int | YES | | NULL | |
| deptid | int | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> select * from Employee;


Empty set (0.00 sec)

mysql> desc emp;


ERROR 1146 (42S02): Table 'batch7pm.emp' doesn't exist
mysql> create table Employee(empid int primary key,empname varchar,region
varchar(40),salary int, deptid 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 ',region
varchar(40),salary int, deptid int)' at line 1
mysql> desc employee;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| empid | int | NO | PRI | NULL | |
| empname | varchar(40) | YES | | NULL | |
| region | varchar(40) | YES | | NULL | |
| salary | int | YES | | NULL | |
| deptid | int | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> insert into employee values(101,"Rohit","West",97000,1);


Query OK, 1 row affected (0.01 sec)

mysql> select * from Employee;


+-------+---------+--------+--------+--------+
| empid | empname | region | salary | deptid |
+-------+---------+--------+--------+--------+
| 101 | Rohit | West | 97000 | 1 |
+-------+---------+--------+--------+--------+
1 row in set (0.00 sec)

mysql> insert into employee values(101,"Sonia","West",97000,1);


ERROR 1062 (23000): Duplicate entry '101' for key 'employee.PRIMARY'
mysql> insert into employee values(NUll,"Sonia","West",97000,1);
ERROR 1048 (23000): Column 'empid' cannot be null
mysql> insert into employee values(102,"Rohit","East",77000,2);
Query OK, 1 row affected (0.01 sec)

mysql> select * from Employee;


+-------+---------+--------+--------+--------+
| empid | empname | region | salary | deptid |
+-------+---------+--------+--------+--------+
| 101 | Rohit | West | 97000 | 1 |
| 102 | Rohit | East | 77000 | 2 |
+-------+---------+--------+--------+--------+
2 rows in set (0.00 sec)

mysql>

You might also like