Intro to MySQL

Home » Tutorials » MySQL tuts » Intro to MySQL
Starting from this lesson we begin to learn mysql database management system and SQL (structure query language). Today we start from basics. Database is complex data which stores in a certain way for further search and management this data.
Database management system is set of software for working with database.
There are two databases types: relational database and non-relational (NoSQL) databases. In NoSQL databases developers management data without sql queries.

Now we’ll talking about MySQL in details. You can download mysql installer from MySQL site. If you use local environment server such as openserver or wampserver they already have necessary tools for work with databases.

MySQL has got two engines: MyISAM and INNOdb. What do you choose? If you are not experienced developer, you can choose INNOdb. There are a lot of differences in these engines. I notice the most important:

  1. INNOdb has got transactions mechanism. MyISAM has not. Transaction is mechanism which allows to rollback data if some error occured.
  2. INNOdb has got foreign keys.
    Necessity of foreign keys we will discuss in next lesson.

Next we’ll create first database and first table.

Code lesson

SHOW DATABASES; #Показать все доступные базы данных. Каждый запрос должен заканчиваться точкой с запятой

CREATE DATABASE mydb; # Создать базу данных с именем mydb

DROP DATABASE mydb; # Удалить базу данных

USE mydb; # Использовать для работы базу данных mydb

CREATE TABLE players (
	player_id int unsigned primary key auto_increment not null,
	player_name varchar(255) not null
);

/*Создание таблици players с полями "id игрока" (это поле является уникальным идентификатором записей в тиблице - ключом) и "имя игрока"*/

SHOW TABLES; # Показать список таблиц в базе данных mydb

DESC players # Описание структуры таблицы players

DROP TABLE players # Удалить таблицу players

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

Pin It on Pinterest

Share This