MySQL Database and Tables

Creating a database :

CREATE DATABASE  YOUR_DATABASE_NAME;
In MySQL  you can display a list of all databases by using this query :
SHOW DATABASES;
Use an existing database using this query :
USE DATABASE_NAME;
  • The SHOW TABLES; query used to display a list of all tables in a database, if this query return a “empty set” message there are no table in the database.

Creating tables :

A MySQL table is created by this query :
CREATE TABLE IF NOT EXISTS table_name(col type, col type)
e.g :
CREATE TABLE IF NOT EXISTS student (
  id int(8) NOT NULL,
  name varchar(8) NOT NULL,
  rollno int(10) NOT NULL
);
You can discover  the format of any table by using these two queries :
EXPLAIN table_name;
DESCRIBE table_name;
Both query will return same result. A table may also be deleted from a database with this query :
DROP TABLE table_name;
]]>

Anuj Kumar

This is Anuj Kumar. I’m a professional web developer with 4+ year experience. I write blogs in my free time. I love to learn new technologies and share with others.
I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials.
.

Recommended Tutorials for you

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.