Familiar with MySQL


How to see existing databases in MySQL server


SHOW databases;



  • You can type this and then click where I circled in red colour.
  • now you see all the databases which are created in your MySQL server.






How to create a database



CREATE DATABASE blog;



  • This code will create a database called blog.
  • Once you create a database it will be not shown in the left side section. You have to refresh on this to see the updates.
  • Then you can see the database that you have created.



How to use a database


USE blog;


  • There are few databases. So you have to select a database to create tables.

How to create a table


USE blog;

CREATE TABLE student 
( 
 id int,
 name varchar(20),
 age int
);


  • You have to go through the syntax and enter the column name and its data type as follows.
  • If your syntax is correct, you can see the message in OUTPUT with green ticks.
  • You need not to mention the size for "int" data type. But if you using "varchar", you have to mention the size within brackets.  



Insert data to the table


INSERT INTO student (id,name,age)
VALUES(1,'John',22),(2,'Ann',18),(3,'Jesmi',26),(4,'Annie',24);







How to see the updates


SELECT * FROM student





These are the very simple SQL queries that I'm gonna use in this series. There are many more things more than this. It is better you can learn the basic commands of MySQL.


You need to understand about, DESCRIBE, DROP, LIKE, DISTINCT, ORDER BY, WHERE... etc.





Familiar with MySQL Familiar with MySQL Reviewed by Ravi Yasas on 8:12 PM Rating: 5

No comments:

Powered by Blogger.