What is MySQL?
MySql is a Relational Database Management Systems(RDBMS). It is open-source database software. It is commonly used in PHP, Python and Node etc. MySql is cross-platform it runs on Mac, Windows and Linux operating systems. It is very fast and easy to use. MySQL uses SQL (Structured Query Language) to manipulate database.
What is a Database?
A Database is a collection of data that is organized in a table format. The main purpose of the database is to store, retrieve, update and manage the data easily.
- Database : db_sample
- Tables in db_sample : categories,customers,orders,order_details,products
A database table is a collection of data elements organized in the form of rows, columns and indexes (Primary Key).
Column or Field :
Each column in a table stores a certain kind of data. For example, the customer_name column contains both text and number values and the customer_id(Primary Key) column contains only integer values.
Row or Record:
Each row in a table represents a group of related information that contains different data types. For example, a single row contains the customer's related information like name, contact and email id.
A query is a commands which is used to retrieve data from a table. Some of commonly used MySQL queries as follows,
create database query is used to create new database.
create database db_sample
use query is used to set database as current database in MySQL.
CREATE TABLE query is used to create table in database.
CREATE TABLE categories ( category_id int(10) unsigned NOT NULL AUTO_INCREMENT, category_name varchar(45) NOT NULL DEFAULT '', PRIMARY KEY (category_id) );
INSERT query is used to insert record into table.
insert into categories (category_name) values ('Toys');
SELECT query is used to fetch records from the table.
SELECT * FROM categories
UPDATE query is used to update the records in the table.
update categories set category_name='Mobiles' where category_id=10
DELETE query is used to delete the records from the table.
delete from categories where category_id=10
TRUNCATE query is used to remove all the records from the table.
Run your MySQL code in online with sample database. Online MySql Query Editor