The document shows the log of a MySQL session where the user connects to a MySQL database, shows existing databases, creates a new database called "balu", creates a table called "students" within that database with four columns, inserts two records into the students table, and selects the records.
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 ratings0% found this document useful (0 votes)
39 views2 pages
SQL Practice
The document shows the log of a MySQL session where the user connects to a MySQL database, shows existing databases, creates a new database called "balu", creates a table called "students" within that database with four columns, inserts two records into the students table, and selects the records.
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/ 2
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 Server version: 8.0.30 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> show databases;
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)
mysql> show databases
-> show databases; 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 'show databases' at line 2 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
mysql> create balu;
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 'balu' at line 1 mysql> create database balu; Query OK, 1 row affected (0.01 sec)
mysql> desc databases;
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 'databases' at line 1 mysql> desc balu; ERROR 1046 (3D000): No database selected mysql> show databases; +--------------------+ | Database | +--------------------+ | balu | | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec)
mysql> select * from balu;
ERROR 1046 (3D000): No database selected mysql> desc balu; ERROR 1046 (3D000): No database selected mysql> use balu; Database changed mysql> create table students (id int(10) NOT NULL PRIMARY KEY,name varchar (40) NOT NULL,age varchar (20) NOT NULL,gender varchar(20) NOT NULL); Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql> select * from students;
Empty set (0.00 sec)
mysql> desc balu;
ERROR 1146 (42S02): Table 'balu.balu' doesn't exist mysql> desc students; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | id | int | NO | PRI | NULL | | | name | varchar(40) | NO | | NULL | | | age | varchar(20) | NO | | NULL | | | gender | varchar(20) | NO | | NULL | | +--------+-------------+------+-----+---------+-------+ 4 rows in set (0.01 sec)
mysql> insert into students values (1,"chari",23,"male"),(2,"santhosh",24,"male");