Jump to content

Archive:PHP and MySQL Programming/Creating a Database: Difference between revisions

From IdeaWazaWiki
wikademia>Ralfe
No edit summary
wikademia>Wikademia
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Programming:PHP and MySQL|TOC]]
== Introduction ==


== Introduction ==
MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. Like fields, rows are in turn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.


MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. LIke rows are inturn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.
Now a days, mysql is the one of the mostly used relational database among others as it is simple, free (free source), easy to maintain and cost effective.


In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a Database.
In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a database.


== SQL Code ==
== SQL Code ==


The code for creating such a database in SQL (Sequential Query Language) is a simple query :
The code for creating such a database in SQL (Sequential Query Language) is a simple query :
 
<br>
  mysql> CREATE DATABASE `database_name`;
  mysql> CREATE DATABASE `database_name`;


== Using the Database ==
== Using the Database ==


After a database has been created, you have to tell MySQL to make it the active database before you can start running further queries on it. You do this as follows :
After a database has been created, you have to tell MySQL that to make it the active database before you can start running further queries on it. You do this as follows :


  mysql> USE `database_name`;
  mysql> USE `database_name`;
[[../Introduction to MySQL/|Previous: Introduction to MySQL]] | [[../|TOC]] | [[../Creating a Table/|Next: Creating a Table]]
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]

Latest revision as of 07:37, 12 June 2009

Introduction

MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. Like fields, rows are in turn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.

Now a days, mysql is the one of the mostly used relational database among others as it is simple, free (free source), easy to maintain and cost effective.

In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a database.

SQL Code

The code for creating such a database in SQL (Sequential Query Language) is a simple query :

mysql> CREATE DATABASE `database_name`;

Using the Database

After a database has been created, you have to tell MySQL that to make it the active database before you can start running further queries on it. You do this as follows :

mysql> USE `database_name`;

[[../Introduction to MySQL/|Previous: Introduction to MySQL]] | [[../|TOC]] | [[../Creating a Table/|Next: Creating a Table]]