How to select Database?

Use Command

Use is very simple and imprtant command for working in database at manual time. It used to select database in sql.

Syntax
USE database_name;
Example
+--------------------+
| Database           |
+--------------------+
| information_schema |
| company            |
| mysql              |
| school             |
| test               |
+--------------------+

mysql> use school
Database changed
mysql> use test;
Database changed
mysql>

Diaplay all Database and Table

Show Command

Use is very simple and important command for working in database at manual time. It used to select database in sql.

Syntax
SHOW database_object;
Example
mysql> SHOW Databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| company            |
| mysql              |
| school             |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql>

mysql> SHOW CREATE Database new_database;
+--------------+-------------------------------------------------------------------------+
| Database     | Create Database                                                         |
+--------------+-------------------------------------------------------------------------+
| new_database | CREATE DATABASE `new_database` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+--------------+-------------------------------------------------------------------------+
1 row in set (0.02 sec)

mysql> SHOW Tables;
+------------------+
| Tables_in_school |
+------------------+
| mark             |
| student          |
+------------------+
2 rows in set (0.07 sec)

mysql>

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

Find Table Structure?

Describe Command

Use is very simple and imprtant command for working in database at manual time. It used to select database in sql.

Syntax
Describe table_name;
Example
mysql> DESC mark; -- use only desc
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.05 sec)

mysql>

mysql> DESCRIBE student;
+--------+----------+------+-----+---------+-------+
| Field  | Type     | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| id     | int(11)  | NO   | PRI | 0       |       |
| fname  | char(15) | YES  |     | NULL    |       |
| lname  | char(15) | YES  |     | NULL    |       |
| gender | char(1)  | YES  |     | T       |       |
+--------+----------+------+-----+---------+-------+
4 rows in set (0.01 sec)

mysql>