Changes

MariaDB

5,390 bytes added, 6 years ago
no edit summary
{{Infobox software| logo = mariadb.png| logo size = 220px| screenshot = | caption = | collapsible =| developer = MariaDB Corporation Ab,MariaDB Foundation| released = {{Start date|2009|1|22}}| discontinued =| programming language = [[C (programming language)|C]], [[C++ (programming language)|C++]], [[Perl]], [[Bash]]| operating system = [[Cross-platform]]| status =| genre = [[Relational database management system|RDBMS]] ([[Embedded database|embedded]])| license = [[GNU GPL]]<ref name="license">{{cite web |url=https://ru.wikipedia.org/wiki/GNU_General_Public_License |title=GNU GPL }}</ref>| website = {{URL|http://www.mariadb.org/}}}}'''MariaDB''' is an enhanced, drop-in replacement for [[MySQL ]] and is available under the terms of the GPL v2 license. It's developed by the MariaDB community with the MariaDB Foundation as its main steward. __TOC__
== General ==
MariaDB is written in [[C(programming language)|C]], [[C++ (programming language)|C++]], [[Perl]], [[Bash]]. MariaDB is cross-platform (Unix, Windows, Solaris, Linux, OS X, BSD). Current stable version is 10.1.13
== Security ==
The MariaDB Foundation is the owner of the main MariaDB server project and owns mariadb.org. This ensures that the official MariaDB development tree will always be open for the MariaDB developer community.
== References Использование ===== Установка ===MySQL и MariaDB используют один и тот же синтаксис команд, поэтому любая из этих систем поддерживает команды из примеров. Для установки MySQL выполните команду:[[MySQL]] and MarisDB use single syntax. Hence, following commands can be used with either DB. <console>sudo apt-get install mysql-server</console> Commands to install MariaDB on Ubuntu 12.04: <console>sudo apt-get updatesudo apt-get install python-software-propertiessudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943dbsudo add-apt-repository 'deb http://repo.maxindo.net.id/mariadb/repo/5.5/ubuntu precise main'sudo apt-get updatesudo apt-get install mariadb-server</console> === Creating DB === Create DB and enter it: <console>mariadb -u root -p</console> Creating DB playground: <syntaxhighlight lang="sql">CREATE DATABASE playground;</syntaxhighlight> Enter DB: <syntaxhighlight lang="sql">USE playground;</syntaxhighlight> === Creating tables === Syntax:<syntaxhighlight lang="sql">CREATE TABLE [IF NOT EXISTS] name_of_table (list_of_table_columns) [engine=database_engine]</syntaxhighlight> Parts in {{ and }} can be dismissed. IF NOT EXISTS points out that table will be created if only it is not in DB already. Otherwise error will occur.Участки в скобках ([ и ]) можно опускать. Фраза IF NOT EXISTS указывает на то, что таблица будет создана только в том случае, если она отсутствует в БД. В противном случае возникнет ошибка. <syntaxhighlight lang="sql">CREATE TABLE IF NOT EXISTS equipment ( equip_id int(5) NOT NULL AUTO_INCREMENT, type varchar(50) DEFAULT NULL, install_date DATE DEFAULT NULL, color varchar(20) DEFAULT NULL, working bool DEFAULT NULL, location varchar(250) DEFAULT NULL, PRIMARY KEY(equip_id));Query OK, 0 rows affected (0.03 sec)</syntaxhighlight> === Data input=== Input syntax:<syntaxhighlight lang="sql">INSERT INTO table_name (field1, field2, ...) VALUES (value1, value2, ...);</syntaxhighlight> All string value should be in quotes. <syntaxhighlight lang="sql">INSERT INTO equipment (type, install_date, color, working, location)VALUES("Slide", Now(), "blue", 1, "Southwest Corner");</syntaxhighlight> We used in-built function now(), that return current date. To read all data we need to send request. * is a special symbol, that indicates selecting all rows: <syntaxhighlight lang="sql">SELECT * FROM equipment;+----------+-------+--------------+-------+---------+------------------+| equip_id | type | install_date | color | working | location |+----------+-------+--------------+-------+---------+------------------+| 1 | Slide | 2013-07-26 | blue | 1 | Southwest Corner |+----------+-------+--------------+-------+---------+------------------+1 row in set (0.00 sec)</syntaxhighlight> Add another row: <syntaxhighlight lang="sql">INSERT INTO equipment (type, install_date, color, working, location)VALUES("Swing", Now(), "green", 1, "Northwest Corner");</syntaxhighlight> Check it: <syntaxhighlight lang="sql">SELECT * FROM equipment;+----------+-------+--------------+-------+---------+------------------+| equip_id | type | install_date | color | working | location |+----------+-------+--------------+-------+---------+------------------+| 1 | Slide | 2013-07-26 | blue | 1 | Southwest Corner || 2 | Swing | 2013-07-26 | green | 1 | Northwest Corner |+----------+-------+--------------+-------+---------+------------------+2 rows in set (0.00 sec)</syntaxhighlight> === Deleting tables === For deleting should be used this command: <syntaxhighlight lang="sql">DROP TABLE table_name;</syntaxhighlight> Be careful, this can't be undone <syntaxhighlight lang="sql">SHOW tables;+----------------------+| Tables_in_playground |+----------------------+| equipment |+----------------------+1 row in set (0.00 sec)</syntaxhighlight> Delete our only table: <syntaxhighlight lang="sql">DROP TABLE equipment;</syntaxhighlight> Check it: <syntaxhighlight lang="sql">SHOW tables;Empty set (0.00 sec)</syntaxhighlight> == Links ==
* [https://en.wikipedia.org/wiki/MariaDB Wiki]
* [https://mariadb.org Official web-page]
* [https://mariadb.com/kb/en/mariadb/documentation/ Documentation]
* [https://seravo.fi/2015/10-reasons-to-migrate-to-mariadb-if-still-using-mysql 10 reasons to migrate to MariaDB]
 
== References ==
{{reflist}}
 
[[ru:MariaDB]]
Editors
494
edits