Wednesday 20 February 2013

SQL Show Commands


SQL Show Database

SQL Show Database Query is for showing a list of Databases available on Database server. If you are using GUI software to access your database (Query Analyzer or PHPMYAdmin) then you will be able to see the list of available databases in the software. But if you are using a Shell or Console (DOS) then to see list of available databases, the show databases query is useful.
SYNTAX:
Show databases;


EXAMPLE:
Show databases;


DESCRIPTION:
Show database query is used to show all the databases on MYSQL Server. When you install a new mysql Server, by default it will come with one or two databases. That’s why if you use show database command; you will be able to see those databases.


SQL Use Database

SQL Use Database Query is use to use a database from Database Server. Suppose we have many databases on our database server and we want to see one database, for manipulation or anything else, we will need to use Database Query.
SYNTAX:
Use name_of_database;

EXAMPLE:
use student;
DESCRIPTION:
Use command is used to enter into a database. If you can see a list of databases using show command, then to enter into a database, say the name of database is student, you can type “use student;”. This command will take you inside a database.


You can think of this command as double click of mouse. When you double click an icon in your computer, you enter into that section of your computer. In the same way when by using “use student;” query you can enter into a database called student.


SQL Show Tables

SQL Show table Query is for showing a list of tables from a database available on Database server. If you are using GUI software to access your database (Query Analyzer or PHPMYAdmin) then you will be able to see the list of available tables by just using mouse. But if you are using a Shell or Console (DOS) then to see list of available tables, the show table’s query is useful.
SYNTAX:
Show Tables;


EXAMPLE:
Show Tables;


DESCRIPTION:
Show tables command is used for showing you all the tables inside a database. To use this command, first you need to go inside a database by using use name-of-database command. Once you are inside a database, then you can easily use show tables command to see all the tables inside a database.

It’s same like, when you want to read chapters from a book, first you need to open the book and then you can go through chapters

SQL Show Columns

 SQL Show columns Query is for showing the structure of tables. For example what are the different columns in available in a table, what are their datatypes etc.

SYNTAX:
Show Columns from Nameoftable
EXAMPLE:
Show Columns From items


DESCRIPTION:
“SHOW COLUMNS” is used to see all the columns from a table. For instance, if you have a table named items, you can view all the columns of this table by using show columns from nameoftable query.

No comments:

Post a Comment