Home Sql Mysql-example Mysql List
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Mysql List

Advertisement
Mysql List elaborate you an Query for listing databases, tables, Procedure, columns, usernames and its password.

Mysql List

     

Mysql List elaborate you an Query for listing databases, tables, Procedure, columns, usernames and its password.

Understand with Example

The Tutorial illustrate an example from 'Mysql List'. To grasp this example, We show you the list of Query for viewing the details of databases,tables,Procedure,columns,usernames and its password.

show databases: The Query is used to view the list of databases.

 

 

 

Query for listing databases:

mysql> show databases;

Output:-

+--------------------+
| Database           |
+--------------------+
| information_schema |
| girish             |
| livetechcom        |
| mysql              |
| test               |
+--------------------+
5 rows in set (0.31 sec)

Query for listing tables:

Now you want to view the tables in database 'girish'.We use show tables Query  that return the tables available in database. 

mysql> use girish;
Database changed
mysql> show tables;

Output:-

+------------------+
| Tables_in_girish |
+------------------+
| emp              |
| employee         |
| employee01       |
| employee02       |
| employee1        |
| employee2        |
| employee3        |
| employee_log     |
| employees1       |
| employeetotal    |
| emptotal         |
| girish           |
| loadedemployee   |
| news             |
| newscategories   |
| newscount        |
| newstrack        |
| person           |
| roseindia        |
| shelf            |
| stu              |
| stu_table        |
| stu_table1       |
| t1               |
| t2               |
| timetable        |
| total            |
+------------------+
27 rows in set (0.00 sec)

Query for listing Procedure:

The Query given below is used to show the status of procedure like Database, Name of the procedure,Definer,Modified,created and Security type.

mysql> show procedure status;

Output:-

+--------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+
| Db     | Name         | Type      | Definer        | Modified            | Created             | Security_type | Comment |
+--------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+
| girish | ABC          | PROCEDURE | root@localhost | 2009-01-05 12:05:24 | 2009-01-05 12:05:24 | DEFINER       |         |
| girish | employeetest | PROCEDURE | root@localhost | 2008-12-31 12:09:16 | 2008-12-31 11:55:32 | INVOKER       |         |
| girish | myloop       | PROCEDURE | root@localhost | 2009-01-02 16:56:11 | 2009-01-02 16:56:11 | DEFINER       |         |
+--------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+
3 rows in set (0.16 sec)

Query for listing Columns of a table:

The Query given below is used to see columns detail from table 'employee1'. 

mysql> show columns from employee1;

Output:-

+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| Empid | varchar(30)  | YES  |     | NULL    |       |
| Name  | varchar(100) | YES  |     | NULL    |       |
| DOB   | date         | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
3 rows in set (0.02 sec)

Query for listing User's:

The user's wish to know the host, username and password. The user's can easily access it by running the given below query as:

mysql> SELECT Host, User, Password FROM mysql.user;

Output:-

+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *7B8F89B33F919D352A9BA5A71FAFBE1AFF1E8277 |
| %         | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
2 rows in set (0.00 sec)
Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 17, 2009

Ask Questions?    Discuss: Mysql List   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com