Basic MySQL Commands for Begineers

ADVERTISEMENT

Here are the basic commands for MySQL beginners

ADVERTISEMENT
Article will continue after the ad

 

 

 

1. How to login mysql from GNU/Linux shell ?

$mysql -h hostname -u root -p

2. How to create a database ?

mysql> create database [Database_Name];

3. How to list all databases ?

mysql> show databases;

4. How to list all the tables in a database ?

mysql> show tables;

5. How to switch to a database ?

mysql> use [Database_Name];

6. How to list database field formats in a table ?

mysql> describe [Table_Name];

7. How to delete a database ?

mysql> drop database [Database_Name];

8. How to delete a table ?

mysql> drop table [Table_Name];

9. How to list all data in a table ?

mysql> SELECT * FROM [Table_Name];

10. How to list certain selected rows with the value “yes”.

SELECT * FROM [Table_Name] WHERE [Field_Name] = “yes”;

11. How to list all records containing the name “verman” AND the phone number ’26235208′.

SELECT * FROM [Table_name] WHERE [Field_Name] = “verman” AND [Field_Name] = ’26235208′;

12. How to list all records not containing the name “verman” AND the phone number ’26235208′ order by the Field_Name phone_number ?

SELECT * FROM [Table_Name] WHERE name != “verman” AND phone_number = ’26235208′ order by phone_number;

13. How to list all records starting with the letters ‘verman’ AND the phone number ’26235208′ ?

SELECT * FROM [Table_Name] WHERE name like “verman%” AND phone_number = ’26235208′;

 

Original Author: MS. Verman

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

Shares