SlideShare a Scribd company logo
1 of 35
Download to read offline
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
1
MariaDB : About MariaDB
Jong Jin Lee
SYS4U I&C EC Solution Lab / Software Engineer
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
2
Agenda
• MariaDB ?
• Install MariaDB
• Starting MariaDB & Query Execution
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
3
Percona Server
MariaDB : Feature
Free & Open Software
• Open source Software
• Developer Based on
MySQL Community
Version
• Patches, Bug fixes and
Feature enhancements
(MySQL Community +
Monty Program AB)
• Development,
Roadmap, Release
Cycle and Other issues
are Open for
community User
Feature enhanced
• New Storage Engine
(PBXT, XtraDB, Maria,
FederatedX)
• Virtual Columns
• Services for Plugins
• Optimization
• Enhancement roadmap
is publicly available on
the wiki
• Backward Compatible
• Percona Server
(Developer Based on
MySQL Server, Onther
MySQL Fork Version)
MySQL Source Code
Maria DB
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
4
• MariaDB Server
• GNU General Public
License (“GPL”)
• Client Program / Library
• GUN Lesser General
Public License
(“LGPL”)
• Community Vesion
• GNU General Public
License (“GPL”)
MariaDB : Licensing Comparison
• Commercially licensed
• Companies choose
between Named User
and Per Processor
pricing models
• Standard vs. Enterprise
vs. Personal vs.
StandardOne
• Per Processor model
has multi-core
implications
• Dual licensed:
• GNU General Public
License (“GPL”)
• Commercial License
• MySQL in enterprise
use:
• Annual Subscription:
per server
• MySQL in embedded
use:
• License - per server
• Annual Support - per
server
• MySQL Cluster CGE:
• Annual Subscription
• License + Annual
Support
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
5
MariaDB : Processes and Threads
Oracle DATABASE
HR SCOTT SH
Table
Index
DB
Schemas
Multi-
Processes
DATAFILE
Network
File
SMON
PMON
CKPT
DBWn
ARCx MYSQLD
My.CNF
INFORMATION
SCHEMA
ORADEMO TEST DB
Single –
Process
Multi
Threads
Table
Index
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
6
MariaDB : Memory and Files
Oracle MySQL
Memory cache •PGA (per server process)
•Hash area •Join Buffer (per client session)
•Sort area •Sort Buffer (per client session)
•Stack area •stack (per client session)
•SGA
•Shared pool •(Query Cache)
•DB buffer cache •Key Buffer [MyISAM]
•InnoDB Buffer Cache [InnoDB]
•REDO log buffer •InnoDB Log Buffer [InnoDB]
Files •init.ora •my.cnf / my.ini
•System tablespace file •`mysql` directory
•User tablespace files •directories in `data` directory
•InnoDB tablespace files [InnoDB]
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
7
MariaDB : Redo & Undo Logs
Oracle MySQL
REDO/UNDO
Logs
•REDO logs •InnoDB logs [InnoDB]
•Binary log
•Archive logs •Binary log
•UNDO tablespace files •InnoDB tablespace files [InnoDB]
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
8
MariaDB : Security
Security Item Oracle MySQL
Built-in Accounts SYS, SYSTEM, others Root.
Object Privileges Handled GRANT, REVOKE GRANT, REVOKE. Host
consideration
Privilege Granularity Column, Row Column (row via view)
Group Management ROLES On Roadmap
SSL Supported Yes Yes
Encryption Transparent, RC4, DES, AES,
etc.
AES, DES, MD5 SHA1;
128/256
Auditing Audit subsystem Handled via logging
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
9
MariaDB : Data Types
Oracle Datatype MySQL Datatype
CHAR, VARCHAR(2),
NCHAR, NVARCHAR
CHAR, VARCHAR, TEXT
CLOB, LONG LONGTEXT
RAW MEDIUMBLOB
LONG RAW, BLOB BLOB
BFILE None
Oracle Datatype MySQL Datatype
NUMBER, DECIMAL INT, BIGINT, DECIMAL
NUMBER (P,S), DECIMAL (P,S) DECIMAL (P,S)
REAL, DOUBLE DECIMAL
FLOAT DOUBLE
DATE, TIMESTAMP DATETIME,TIMESTAMP
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
10
MariaDB : Storage Engine
Purpose MariaDB MySQL
Memory Engine Memory Memory
Based on Disk : Temp
Table Engine
Aria MyISAM
Transaction Engine XtraDB InnoDB
NOSQL Support Engine MariaDB 10.0 Over :Cassandra Memcached API (Plug-in)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
11
MariaDB : Comparison
MariaDB MySQL
Thread Pool MariaDB 5.1 Over MySQL 5.5 Enterprise (Not
Support Community Vesion)
Buffer Pool MariaDB 5.5 Over : XtraDB MySQL 5.6 Over : InnoDB
Support SSD
(Solid-state Drive)
MariaDB 5.5 Over : XtraDB
Virtual Columns MariaDB 5.2 Over
Role Management MariaDB 10.0 Over
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
12
MariaDB : Version-specific compatibility
MariaDB MySQL
5.1, 5.2, 5.3 5.1
5.5, 10.0 5.5
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
13
MariaDB : Installation Step
[root@sys4u ~]# groupadd -g 600 dba
[root@sys4u ~]# useradd -g 600 -u 605 mysql
[root@sys4u ~]# usermod -g 600 mysql
[root@sys4u ~]# usermod -u 605 mysql
[root@sys4u ~]# passwd mysql
Changing password for user mysql.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# vi /etc/security/limits.conf
# Below the line
mysql soft nproc 8192
mysql hard nproc 16384
mysql soft nofile 8192
mysql hard nofile 65536
# vi /etc/pam.d/login
# Below the line
session required pam_limits.so
# vi /etc/profile
# Below the line
if [ $USER = "mysql" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
14
MariaDB : Installation Step
[root@sys4u ~]# mkdir -p /home/mariadb
[root@sys4u ~]# mkdir -p /home/data/mariadb-data
[root@sys4u ~]# mkdir -p /home/data/mariadb-tmp
[root@sys4u ~]# mkdir -p /home/data/mariadb-iblog
[root@sys4u ~]# mkdir -p /home/data/mariadb-binlog
[root@sys4u ~]# chown -R mysql:dba /home/mariadb/
[root@sys4u ~]# chown -R mysql:dba /home/data/*
[root@sys4u mariadb]# ls
cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz
[root@sys4u mariadb]# tar -xvf cmake-2.8.4
[root@sys4u mariadb]# ls
cmake-2.8.4 cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz
[root@sys4u mariadb]# cd cmake-2.8.4
[root@sys4u cmake-2.8.4]# ls
CMakeCPack.cmake ChangeLog.txt Source
CMakeCPackOptions.cmake.in CompileFlags.cmake Templates
CMakeGraphVizOptions.cmake Copyright.txt Tests
CMakeLists.txt DartConfig.cmake Utilities
CMakeLogo.gif DartLocal.conf.in bootstrap
CTestConfig.cmake Docs cmake.1
CTestCustom.cmake.in Example cmake_uninstall.cmake.in
CTestCustom.ctest.in Modules configure
ChangeLog.manual Readme.txt doxygen.config
[root@sys4u cmake-2.8.4]# ./bootstrap
---------------------------------------------
-----
-----
---------------------------------------------
Log of errors: /home/mariadb/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
15
MariaDB : Installation Step
[[root@sys4u cmake-2.8.4]# yum -y install gcc-c++
-----
Loaded plugins: fastestmirror, security
base | 3.7 kB 00:00
base/primary_db | 4.4 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 19 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
-----
[root@sys4u cmake-2.8.4]# ./bootstrap
-----
Makefile processor on this system is: gmake
g++ is GNU compiler
g++ has STL in std:: namespace
g++ has ANSI streams
g++ has streams in std:: namespace
g++ has sstream
g++ has operator!=(string, char*)
g++ has stl iterator_traits
g++ has standard template allocator
g++ has allocator<>::rebind<>
g++ does not have non-standard allocator<>::max_size argument
-----
[root@sys4u cmake-2.8.4]# make
-----
Scanning dependencies of target cmsys
[ 1%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Terminal.o
[ 2%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/System.o
-----
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
16
MariaDB : Installation Step
[root@sys4u cmake-2.8.4]# make install
-----
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/doc/cmake-2.8/Copyright.txt
-- Installing: /usr/local/share/cmake-2.8/Modules
-- Installing: /usr/local/share/cmake-2.8/Modules/FindPerl.cmake
-- Installing: /usr/local/share/cmake-2.8/Modules/FindLibArchive.cmake
-- Installing: /usr/local/share/cmake-2.8/Modules/CMakeDetermineASMCompiler.cmake
-- Installing: /usr/local/share/cmake-2.8/Modules/CMakeExportBuildSettings.cmake
-- Installing: /usr/local/share/cmake-2.8/Modules/FindJPEG.cmake
-----
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
17
MariaDB : Installation Step
# vi /etc/my.cnf
-----
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
#user=mysql
## Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
#[mysqld_safe]
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
[client]
port = 3306
socket = /usr/local/mysql/mysql.socket
[mysqld]
# generic configuration options
port = 3306
socket = /usr/local/mysql/mysql.socket
back_log = 100
max_connections = 500
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
join_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
thread_stack = 192K
lower_case_table_names = 0
-----
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
18
MariaDB : Installation Step
[root@sys4u cmake-2.8.4]# cd /home/mariadb/
[root@sys4u mariadb]# ls
cmake-2.8.4 cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz
[root@sys4u mariadb]# tar -xvf mariadb-5.5.30.tar.gz
-----
mariadb-5.5.30/mysql-test/suite/sys_vars/r/warning_count_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/thread_stack_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/default_week_format_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/collation_server_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/shared_memory_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/innodb_log_group_home_dir_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/general_log_file_func.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/thread_pool_size_basic.result
mariadb-5.5.30/mysql-test/suite/sys_vars/r/sync_master_info_basic.result
-----
[root@sys4u mariadb-5.5.30]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DMYSQL_DATADIR=/usr/local/mysql/data -
DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.socket
-----
-- Looking for access - found
-- Looking for aio_read
-- Looking for aio_read - found
-- Looking for alarm
-- Looking for alarm - found
-- Looking for backtrace
-- Looking for backtrace - found
-- Looking for backtrace_symbols
-- Looking for backtrace_symbols - found
-- Looking for backtrace_symbols_fd
-----
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
19
MariaDB : Installation Step
[root@sys4u mysql]# chown -R mysql:dba /usr/local/mysql*
[root@sys4u mysql]# chown mysql:dba /etc/my.cnf
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin:.
export ADMIN_PWD="root password”
alias ll="ls -al --color=auto"
alias mydba="mysql -uroot -p$ADMIN_PWD"
alias mymaster="mysql -uroot -p$ADMIN_PWD -e'show master status;'"
alias myslave="mysql -uroot -p$ADMIN_PWD -e'show slave statusG'"
alias mh="cd $MYSQL_HOME"
alias md="cd /home/data/mariadb-data"
alias mt="cd /home/data/mariadb-tmp“
-----
[root@sys4u mysql]# cd /usr/local/mysql/
[root@sys4u mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/
-----
WARNING: The host 'sys4u.co.kr' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MariaDB version. The MariaDB daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MariaDB privileges !
Installing MariaDB/MySQL system tables in '/home/data/mariadb-data' ...
OK
-----
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
20
MariaDB : Installation Step
[root@sys4u ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp: overwrite `/etc/init.d/mysqld'? y
# /etc/init.d/mysqld
46 basedir=/home/mariadb
47 datadir=/home/data/mariadb-data
[root@sys4u ~]# /usr/local/mysql/bin/mysql
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.30-MariaDB-log Source distribution
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
21
MariaDB : Installation Step
MariaDB [(none)]> use mysql
Database changed
MariaDB [mysql]> create database orademo;
Query OK, 1 row affected (0.00 sec)
MariaDB [mysql]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| orademo |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by ‘’ecsses;
Query OK, 0 rows affected (0.03 sec)
MariaDB [mysql]> select host, user, password from user;
+-------------+------+-------------------------------------------+
| host | user | password |
+-------------+------+-------------------------------------------+
| localhost | root | |
| sys4u.co.kr | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| sys4u.co.kr | | |
| % | root | *077D2C382FBC8EF28EFF2EF07C9BAD1595F0AB6D |
+-------------+------+-------------------------------------------+
7 rows in set (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
22
MariaDB : MariaDB Server Startup & Shutdown
[root@sys4u ~]# /etc/init.d/mysqld start
Starting MySQL.... [ OK ]
[root@sys4u ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 5.5.37-tokudb-7.1.6-MariaDB-log MariaDB Server
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]> use mysql
Database changed
MariaDB [mysql]> exit
Bye
[root@sys4u ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. [ OK ]
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
23
MariaDB : Create DB & User
MariaDB [(none)]> create database firstdb; (or create database firstdb default charcter set utf8mb4;)
Query OK, 1 row affected (0.03 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| firstdb |
| mysql |
| orademo |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.10 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
24
MariaDB : Create DB & User
MariaDB [(none)]> create database firstdb; (or create database firstdb default charcter set utf8mb4;)
Query OK, 1 row affected (0.03 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| firstdb |
| mysql |
| orademo |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.10 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
25
MariaDB : Create Table
MariaDB [firstdb]> create table tab_test (
-> tid bigint not null auto_increment,
-> tname varchar(100) not null,
-> tmeno text not null,
-> primary key(tid),
-> index ix_tname_tid (tname, tid)
-> ) ENGINE=InnoDB;
MariaDB [firstdb]> show create table tab_test;
------------+
| Table | Create Table |
+----------+-----------------------------------------------------------------------------------------------------
| tab_test | CREATE TABLE `tab_test` (
`tid` bigint(20) NOT NULL AUTO_INCREMENT,
`tname` varchar(100) NOT NULL,
`tmeno` text NOT NULL,
PRIMARY KEY (`tid`),
KEY `ix_tname_tid` (`tname`,`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+----------+-----------------------------------------------------------------------------------------------------
------------+
1 row in set (0.11 sec)
MariaDB [firstdb]> desc tab_test;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| tid | bigint(20) | NO | PRI | NULL | auto_increment |
| tname | varchar(100) | NO | MUL | NULL | |
| tmeno | text | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
26
MariaDB : Modify table (ONLINE/OFFLINE)
MariaDB [firstdb]> create table t1 (fd1 int, fd2 enum('red', 'green'));
Query OK, 0 rows affected (0.00 sec)
MariaDB [firstdb]> alter online table t1 modify fd2 enum('red', 'green', 'blue');
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [firstdb]> alter online table t1 add fd3 int;
ERROR 1915 (HY000): Can't execute the given 'ALTER' command as online
 Don't Need : Data Copy to Temp Table
– Modify Table Names
– Modify Column Names
– Modify Number Type Column Length
– Modify Table Comment
– ENUM Type item add
Online Modify Schema : MariaDB 10.0, MySQL 5.6 Over
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
27
MariaDB : Modify table (ONLINE/OFFLINE)
MariaDB [firstdb]> alter table tab_test add created datetime not null;
Query OK, 0 rows affected (0.30 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [firstdb]> alter table tab_test add index ix_created (created);
Query OK, 0 rows affected (0.18 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [firstdb]> desc tab_test;
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| tid | bigint(20) | NO | PRI | NULL | auto_increment |
| tname | varchar(100) | NO | MUL | NULL | |
| tmeno | text | NO | | NULL | |
| created | datetime | NO | MUL | NULL | |
+---------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
28
MariaDB : DML (INSERT)
MariaDB [firstdb]> create table tab_test (
-> fd1 int not null,
-> fd2 varchar(50),
-> primary key(fd1)) engine=innodb;
Query OK, 0 rows affected (0.09 sec)
MariaDB [firstdb]> insert into tab_test (fd1, fd2) values (1,'Matt');
Query OK, 1 row affected (0.06 sec)
MariaDB [firstdb]> insert into tab_test values (2, 'Toto');
Query OK, 1 row affected (0.00 sec)
MariaDB [firstdb]> insert into tab_test(fd1, fd2)
-> values (3,'Lee') on duplicate key update fd2='Lee';
Query OK, 1 row affected (0.03 sec)
MariaDB [firstdb]> insert into tab_test(fd1, fd2)
-> values (3, 'SeongUck') on duplicate key update fd2='SeongUck';
Query OK, 2 rows affected (0.04 sec)
MariaDB [firstdb]> select * from tab_test;
+-----+----------+
| fd1 | fd2 |
+-----+----------+
| 1 | Matt |
| 2 | Toto |
| 3 | SeongUck |
+-----+----------+
3 rows in set (0.00 sec)
Option) ON DUPLICATE KEY UPDATE
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
29
MariaDB : DML (SELECT)
MariaDB [firstdb]> select * from tab_test;
+-----+----------+
| fd1 | fd2 |
+-----+----------+
| 1 | Matt |
| 2 | Toto |
| 3 | SeongUck |
+-----+----------+
3 rows in set (0.00 sec)
MariaDB [firstdb]> select * from tab_testG;
*************************** 1. row ***************************
fd1: 1
fd2: Matt
*************************** 2. row ***************************
fd1: 2
fd2: Toto
*************************** 3. row ***************************
fd1: 3
fd2: SeongUck
3 rows in set (0.00 sec)
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
30
MariaDB : DML (UPDATE)
MariaDB [firstdb]> update tab_test set fd2='Brandon' where fd1=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [firstdb]> select * from tab_test where fd1=1;
+-----+---------+
| fd1 | fd2 |
+-----+---------+
| 1 | Brandon |
+-----+---------+
1 row in set (0.06 sec)
MariaDB [firstdb]> select * from tab_test where fd1=1;
+-----+---------+
| fd1 | fd2 |
+-----+---------+
| 1 | Brandon |
+-----+---------+
1 row in set (0.06 sec)
MariaDB [firstdb]> update tab_test set fd2='Brandon';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 3 Changed: 2 Warnings: 0
MariaDB [firstdb]> select * from tab_test;
+-----+---------+
| fd1 | fd2 |
+-----+---------+
| 1 | Brandon |
| 2 | Brandon |
| 3 | Brandon |
+-----+---------+
3 rows in set (0.01 sec)
caution
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
31
MariaDB : DML (REPLACE)
MariaDB [firstdb]> replace tab_test set fd1=1, fd2='Matt';
Query OK, 2 rows affected (0.00 sec)
MariaDB [firstdb]> select * from tab_test where fd1=1;
+-----+------+
| fd1 | fd2 |
+-----+------+
| 1 | Matt |
+-----+------+
1 row in set (0.00 sec)
 REPLACE <-> UPDATE
– If, PK or Unique key : Recode Delete & Insert
– System Over head
– Recommended : INSERT INTO … ON DUPLICATE KEY UP-DATE
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
32
MariaDB : DML (DELETE)
MariaDB [firstdb]> delete from tab_test where fd1=1;
Query OK, 0 rows affected (0.00 sec)
MariaDB [firstdb]> select * from tab_test;
+-----+---------+
| fd1 | fd2 |
+-----+---------+
| 2 | Brandon |
| 3 | Brandon |
+-----+---------+
2 rows in set (0.00 sec)
MariaDB : AUTO Commit
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
33
Reference
 Presentation : Ryusuke Kajiyama (MySQL Sales Consulting Manager, JAPAC)
– State of the Dolphin
– MySQL for Oracle DB
 Site : MariaDB Knowledge Base
 Book : “Real MariaDB”
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
34
Q & A
Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee
Blog : http://ora-sysdba.tistory.com/
35

More Related Content

What's hot

MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
Wagner Bianchi
 

What's hot (20)

MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
 
Database Security Threats - MariaDB Security Best Practices
Database Security Threats - MariaDB Security Best PracticesDatabase Security Threats - MariaDB Security Best Practices
Database Security Threats - MariaDB Security Best Practices
 
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScaleThe Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
 
Maxscale switchover, failover, and auto rejoin
Maxscale switchover, failover, and auto rejoinMaxscale switchover, failover, and auto rejoin
Maxscale switchover, failover, and auto rejoin
 
M|18 Architectural Overview: MariaDB MaxScale
M|18 Architectural Overview: MariaDB MaxScaleM|18 Architectural Overview: MariaDB MaxScale
M|18 Architectural Overview: MariaDB MaxScale
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
Transparent sharding with Spider: what's new and getting started
Transparent sharding with Spider: what's new and getting startedTransparent sharding with Spider: what's new and getting started
Transparent sharding with Spider: what's new and getting started
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
 
How to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScaleHow to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScale
 
mysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementmysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancement
 
MariaDB Other Features
MariaDB Other FeaturesMariaDB Other Features
MariaDB Other Features
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & Optimization
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
 
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresql
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 

Viewers also liked

Seminar Presentation Hadoop
Seminar Presentation HadoopSeminar Presentation Hadoop
Seminar Presentation Hadoop
Varun Narang
 
Unidad 2. modelo entidad relacion
Unidad 2. modelo entidad relacionUnidad 2. modelo entidad relacion
Unidad 2. modelo entidad relacion
LuiS YmAY
 

Viewers also liked (20)

Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
 
A beginners guide to MariaDB
A beginners guide to MariaDBA beginners guide to MariaDB
A beginners guide to MariaDB
 
MariaDB - Fast, Easy & Strong - Get Started Tutorial
MariaDB - Fast, Easy & Strong - Get Started TutorialMariaDB - Fast, Easy & Strong - Get Started Tutorial
MariaDB - Fast, Easy & Strong - Get Started Tutorial
 
Maria db vs mysql
Maria db vs mysqlMaria db vs mysql
Maria db vs mysql
 
The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015
 
Elk stack
Elk stackElk stack
Elk stack
 
Apache Spark 2.0: Faster, Easier, and Smarter
Apache Spark 2.0: Faster, Easier, and SmarterApache Spark 2.0: Faster, Easier, and Smarter
Apache Spark 2.0: Faster, Easier, and Smarter
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Seminar Presentation Hadoop
Seminar Presentation HadoopSeminar Presentation Hadoop
Seminar Presentation Hadoop
 
State of MariaDB
State of MariaDBState of MariaDB
State of MariaDB
 
SQLite en Unity3D
SQLite en Unity3DSQLite en Unity3D
SQLite en Unity3D
 
MariaDB Optimizer
MariaDB OptimizerMariaDB Optimizer
MariaDB Optimizer
 
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonMariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
 
Introducción a los Modelos De Datos
Introducción a los Modelos De DatosIntroducción a los Modelos De Datos
Introducción a los Modelos De Datos
 
Unidad 2. modelo entidad relacion
Unidad 2. modelo entidad relacionUnidad 2. modelo entidad relacion
Unidad 2. modelo entidad relacion
 
Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...
 
Maria DB Galera Cluster for High Availability
Maria DB Galera Cluster for High AvailabilityMaria DB Galera Cluster for High Availability
Maria DB Galera Cluster for High Availability
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
MariaDBのススメ
MariaDBのススメMariaDBのススメ
MariaDBのススメ
 
MariaDB Vorstellung
MariaDB VorstellungMariaDB Vorstellung
MariaDB Vorstellung
 

Similar to Introduction to MariaDB

Maria db the new mysql (Colin Charles)
Maria db the new mysql (Colin Charles)Maria db the new mysql (Colin Charles)
Maria db the new mysql (Colin Charles)
Ontico
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
Insight Technology, Inc.
 

Similar to Introduction to MariaDB (20)

Deploying MariaDB databases with containers at Nokia Networks
Deploying MariaDB databases with containers at Nokia NetworksDeploying MariaDB databases with containers at Nokia Networks
Deploying MariaDB databases with containers at Nokia Networks
 
Maria db the new mysql (Colin Charles)
Maria db the new mysql (Colin Charles)Maria db the new mysql (Colin Charles)
Maria db the new mysql (Colin Charles)
 
MariaDB 10.0 - SkySQL Paris Meetup
MariaDB 10.0 - SkySQL Paris MeetupMariaDB 10.0 - SkySQL Paris Meetup
MariaDB 10.0 - SkySQL Paris Meetup
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin FrankfurtMariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
The Complete MariaDB Server tutorial
The Complete MariaDB Server tutorialThe Complete MariaDB Server tutorial
The Complete MariaDB Server tutorial
 
MariaDB 10.2 & MariaDB 10.1 by Michael Monty Widenius at Database Camp 2016 @ UN
MariaDB 10.2 & MariaDB 10.1 by Michael Monty Widenius at Database Camp 2016 @ UNMariaDB 10.2 & MariaDB 10.1 by Michael Monty Widenius at Database Camp 2016 @ UN
MariaDB 10.2 & MariaDB 10.1 by Michael Monty Widenius at Database Camp 2016 @ UN
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
 
The New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and MoreThe New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and More
 
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability Tutorial
 
MariaDB 10 and Beyond
MariaDB 10 and BeyondMariaDB 10 and Beyond
MariaDB 10 and Beyond
 
Azure Nights August2017
Azure Nights August2017Azure Nights August2017
Azure Nights August2017
 
Meet MariaDB 10.1 at the Bulgaria Web Summit
Meet MariaDB 10.1 at the Bulgaria Web SummitMeet MariaDB 10.1 at the Bulgaria Web Summit
Meet MariaDB 10.1 at the Bulgaria Web Summit
 
AAI-4847 Full Disclosure on the Performance Characteristics of WebSphere Appl...
AAI-4847 Full Disclosure on the Performance Characteristics of WebSphere Appl...AAI-4847 Full Disclosure on the Performance Characteristics of WebSphere Appl...
AAI-4847 Full Disclosure on the Performance Characteristics of WebSphere Appl...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
 

Recently uploaded

Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
JoseMangaJr1
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 

Recently uploaded (20)

Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 

Introduction to MariaDB

  • 1. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 1 MariaDB : About MariaDB Jong Jin Lee SYS4U I&C EC Solution Lab / Software Engineer
  • 2. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 2 Agenda • MariaDB ? • Install MariaDB • Starting MariaDB & Query Execution
  • 3. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 3 Percona Server MariaDB : Feature Free & Open Software • Open source Software • Developer Based on MySQL Community Version • Patches, Bug fixes and Feature enhancements (MySQL Community + Monty Program AB) • Development, Roadmap, Release Cycle and Other issues are Open for community User Feature enhanced • New Storage Engine (PBXT, XtraDB, Maria, FederatedX) • Virtual Columns • Services for Plugins • Optimization • Enhancement roadmap is publicly available on the wiki • Backward Compatible • Percona Server (Developer Based on MySQL Server, Onther MySQL Fork Version) MySQL Source Code Maria DB
  • 4. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 4 • MariaDB Server • GNU General Public License (“GPL”) • Client Program / Library • GUN Lesser General Public License (“LGPL”) • Community Vesion • GNU General Public License (“GPL”) MariaDB : Licensing Comparison • Commercially licensed • Companies choose between Named User and Per Processor pricing models • Standard vs. Enterprise vs. Personal vs. StandardOne • Per Processor model has multi-core implications • Dual licensed: • GNU General Public License (“GPL”) • Commercial License • MySQL in enterprise use: • Annual Subscription: per server • MySQL in embedded use: • License - per server • Annual Support - per server • MySQL Cluster CGE: • Annual Subscription • License + Annual Support
  • 5. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 5 MariaDB : Processes and Threads Oracle DATABASE HR SCOTT SH Table Index DB Schemas Multi- Processes DATAFILE Network File SMON PMON CKPT DBWn ARCx MYSQLD My.CNF INFORMATION SCHEMA ORADEMO TEST DB Single – Process Multi Threads Table Index
  • 6. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 6 MariaDB : Memory and Files Oracle MySQL Memory cache •PGA (per server process) •Hash area •Join Buffer (per client session) •Sort area •Sort Buffer (per client session) •Stack area •stack (per client session) •SGA •Shared pool •(Query Cache) •DB buffer cache •Key Buffer [MyISAM] •InnoDB Buffer Cache [InnoDB] •REDO log buffer •InnoDB Log Buffer [InnoDB] Files •init.ora •my.cnf / my.ini •System tablespace file •`mysql` directory •User tablespace files •directories in `data` directory •InnoDB tablespace files [InnoDB]
  • 7. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 7 MariaDB : Redo & Undo Logs Oracle MySQL REDO/UNDO Logs •REDO logs •InnoDB logs [InnoDB] •Binary log •Archive logs •Binary log •UNDO tablespace files •InnoDB tablespace files [InnoDB]
  • 8. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 8 MariaDB : Security Security Item Oracle MySQL Built-in Accounts SYS, SYSTEM, others Root. Object Privileges Handled GRANT, REVOKE GRANT, REVOKE. Host consideration Privilege Granularity Column, Row Column (row via view) Group Management ROLES On Roadmap SSL Supported Yes Yes Encryption Transparent, RC4, DES, AES, etc. AES, DES, MD5 SHA1; 128/256 Auditing Audit subsystem Handled via logging
  • 9. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 9 MariaDB : Data Types Oracle Datatype MySQL Datatype CHAR, VARCHAR(2), NCHAR, NVARCHAR CHAR, VARCHAR, TEXT CLOB, LONG LONGTEXT RAW MEDIUMBLOB LONG RAW, BLOB BLOB BFILE None Oracle Datatype MySQL Datatype NUMBER, DECIMAL INT, BIGINT, DECIMAL NUMBER (P,S), DECIMAL (P,S) DECIMAL (P,S) REAL, DOUBLE DECIMAL FLOAT DOUBLE DATE, TIMESTAMP DATETIME,TIMESTAMP
  • 10. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 10 MariaDB : Storage Engine Purpose MariaDB MySQL Memory Engine Memory Memory Based on Disk : Temp Table Engine Aria MyISAM Transaction Engine XtraDB InnoDB NOSQL Support Engine MariaDB 10.0 Over :Cassandra Memcached API (Plug-in)
  • 11. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 11 MariaDB : Comparison MariaDB MySQL Thread Pool MariaDB 5.1 Over MySQL 5.5 Enterprise (Not Support Community Vesion) Buffer Pool MariaDB 5.5 Over : XtraDB MySQL 5.6 Over : InnoDB Support SSD (Solid-state Drive) MariaDB 5.5 Over : XtraDB Virtual Columns MariaDB 5.2 Over Role Management MariaDB 10.0 Over
  • 12. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 12 MariaDB : Version-specific compatibility MariaDB MySQL 5.1, 5.2, 5.3 5.1 5.5, 10.0 5.5
  • 13. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 13 MariaDB : Installation Step [root@sys4u ~]# groupadd -g 600 dba [root@sys4u ~]# useradd -g 600 -u 605 mysql [root@sys4u ~]# usermod -g 600 mysql [root@sys4u ~]# usermod -u 605 mysql [root@sys4u ~]# passwd mysql Changing password for user mysql. New password: Retype new password: passwd: all authentication tokens updated successfully. # vi /etc/security/limits.conf # Below the line mysql soft nproc 8192 mysql hard nproc 16384 mysql soft nofile 8192 mysql hard nofile 65536 # vi /etc/pam.d/login # Below the line session required pam_limits.so # vi /etc/profile # Below the line if [ $USER = "mysql" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi
  • 14. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 14 MariaDB : Installation Step [root@sys4u ~]# mkdir -p /home/mariadb [root@sys4u ~]# mkdir -p /home/data/mariadb-data [root@sys4u ~]# mkdir -p /home/data/mariadb-tmp [root@sys4u ~]# mkdir -p /home/data/mariadb-iblog [root@sys4u ~]# mkdir -p /home/data/mariadb-binlog [root@sys4u ~]# chown -R mysql:dba /home/mariadb/ [root@sys4u ~]# chown -R mysql:dba /home/data/* [root@sys4u mariadb]# ls cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz [root@sys4u mariadb]# tar -xvf cmake-2.8.4 [root@sys4u mariadb]# ls cmake-2.8.4 cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz [root@sys4u mariadb]# cd cmake-2.8.4 [root@sys4u cmake-2.8.4]# ls CMakeCPack.cmake ChangeLog.txt Source CMakeCPackOptions.cmake.in CompileFlags.cmake Templates CMakeGraphVizOptions.cmake Copyright.txt Tests CMakeLists.txt DartConfig.cmake Utilities CMakeLogo.gif DartLocal.conf.in bootstrap CTestConfig.cmake Docs cmake.1 CTestCustom.cmake.in Example cmake_uninstall.cmake.in CTestCustom.ctest.in Modules configure ChangeLog.manual Readme.txt doxygen.config [root@sys4u cmake-2.8.4]# ./bootstrap --------------------------------------------- ----- ----- --------------------------------------------- Log of errors: /home/mariadb/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log ---------------------------------------------
  • 15. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 15 MariaDB : Installation Step [[root@sys4u cmake-2.8.4]# yum -y install gcc-c++ ----- Loaded plugins: fastestmirror, security base | 3.7 kB 00:00 base/primary_db | 4.4 MB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 19 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 3.2 MB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ----- [root@sys4u cmake-2.8.4]# ./bootstrap ----- Makefile processor on this system is: gmake g++ is GNU compiler g++ has STL in std:: namespace g++ has ANSI streams g++ has streams in std:: namespace g++ has sstream g++ has operator!=(string, char*) g++ has stl iterator_traits g++ has standard template allocator g++ has allocator<>::rebind<> g++ does not have non-standard allocator<>::max_size argument ----- [root@sys4u cmake-2.8.4]# make ----- Scanning dependencies of target cmsys [ 1%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Terminal.o [ 2%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/System.o -----
  • 16. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 16 MariaDB : Installation Step [root@sys4u cmake-2.8.4]# make install ----- Install the project... -- Install configuration: "" -- Installing: /usr/local/doc/cmake-2.8/Copyright.txt -- Installing: /usr/local/share/cmake-2.8/Modules -- Installing: /usr/local/share/cmake-2.8/Modules/FindPerl.cmake -- Installing: /usr/local/share/cmake-2.8/Modules/FindLibArchive.cmake -- Installing: /usr/local/share/cmake-2.8/Modules/CMakeDetermineASMCompiler.cmake -- Installing: /usr/local/share/cmake-2.8/Modules/CMakeExportBuildSettings.cmake -- Installing: /usr/local/share/cmake-2.8/Modules/FindJPEG.cmake -----
  • 17. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 17 MariaDB : Installation Step # vi /etc/my.cnf ----- #[mysqld] #datadir=/var/lib/mysql #socket=/var/lib/mysql/mysql.sock #user=mysql ## Disabling symbolic-links is recommended to prevent assorted security risks #symbolic-links=0 #[mysqld_safe] #log-error=/var/log/mysqld.log #pid-file=/var/run/mysqld/mysqld.pid [client] port = 3306 socket = /usr/local/mysql/mysql.socket [mysqld] # generic configuration options port = 3306 socket = /usr/local/mysql/mysql.socket back_log = 100 max_connections = 500 max_connect_errors = 10 table_open_cache = 2048 max_allowed_packet = 16M join_buffer_size = 8M read_buffer_size = 2M read_rnd_buffer_size = 16M sort_buffer_size = 8M thread_stack = 192K lower_case_table_names = 0 -----
  • 18. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 18 MariaDB : Installation Step [root@sys4u cmake-2.8.4]# cd /home/mariadb/ [root@sys4u mariadb]# ls cmake-2.8.4 cmake-2.8.4.tar.gz mariadb-5.5.30.tar.gz [root@sys4u mariadb]# tar -xvf mariadb-5.5.30.tar.gz ----- mariadb-5.5.30/mysql-test/suite/sys_vars/r/warning_count_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/thread_stack_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/default_week_format_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/collation_server_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/shared_memory_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/innodb_log_group_home_dir_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/general_log_file_func.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/thread_pool_size_basic.result mariadb-5.5.30/mysql-test/suite/sys_vars/r/sync_master_info_basic.result ----- [root@sys4u mariadb-5.5.30]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DMYSQL_DATADIR=/usr/local/mysql/data - DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.socket ----- -- Looking for access - found -- Looking for aio_read -- Looking for aio_read - found -- Looking for alarm -- Looking for alarm - found -- Looking for backtrace -- Looking for backtrace - found -- Looking for backtrace_symbols -- Looking for backtrace_symbols - found -- Looking for backtrace_symbols_fd -----
  • 19. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 19 MariaDB : Installation Step [root@sys4u mysql]# chown -R mysql:dba /usr/local/mysql* [root@sys4u mysql]# chown mysql:dba /etc/my.cnf export MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME/bin:. export ADMIN_PWD="root password” alias ll="ls -al --color=auto" alias mydba="mysql -uroot -p$ADMIN_PWD" alias mymaster="mysql -uroot -p$ADMIN_PWD -e'show master status;'" alias myslave="mysql -uroot -p$ADMIN_PWD -e'show slave statusG'" alias mh="cd $MYSQL_HOME" alias md="cd /home/data/mariadb-data" alias mt="cd /home/data/mariadb-tmp“ ----- [root@sys4u mysql]# cd /usr/local/mysql/ [root@sys4u mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ ----- WARNING: The host 'sys4u.co.kr' could not be looked up with resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MariaDB version. The MariaDB daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MariaDB privileges ! Installing MariaDB/MySQL system tables in '/home/data/mariadb-data' ... OK -----
  • 20. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 20 MariaDB : Installation Step [root@sys4u ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld cp: overwrite `/etc/init.d/mysqld'? y # /etc/init.d/mysqld 46 basedir=/home/mariadb 47 datadir=/home/data/mariadb-data [root@sys4u ~]# /usr/local/mysql/bin/mysql Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 2 Server version: 5.5.30-MariaDB-log Source distribution Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]>
  • 21. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 21 MariaDB : Installation Step MariaDB [(none)]> use mysql Database changed MariaDB [mysql]> create database orademo; Query OK, 1 row affected (0.00 sec) MariaDB [mysql]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | orademo | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by ‘’ecsses; Query OK, 0 rows affected (0.03 sec) MariaDB [mysql]> select host, user, password from user; +-------------+------+-------------------------------------------+ | host | user | password | +-------------+------+-------------------------------------------+ | localhost | root | | | sys4u.co.kr | root | | | 127.0.0.1 | root | | | ::1 | root | | | localhost | | | | sys4u.co.kr | | | | % | root | *077D2C382FBC8EF28EFF2EF07C9BAD1595F0AB6D | +-------------+------+-------------------------------------------+ 7 rows in set (0.00 sec) MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec)
  • 22. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 22 MariaDB : MariaDB Server Startup & Shutdown [root@sys4u ~]# /etc/init.d/mysqld start Starting MySQL.... [ OK ] [root@sys4u ~]# /usr/local/mysql/bin/mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 3 Server version: 5.5.37-tokudb-7.1.6-MariaDB-log MariaDB Server Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]> use mysql Database changed MariaDB [mysql]> exit Bye [root@sys4u ~]# /etc/init.d/mysqld stop Shutting down MySQL.. [ OK ]
  • 23. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 23 MariaDB : Create DB & User MariaDB [(none)]> create database firstdb; (or create database firstdb default charcter set utf8mb4;) Query OK, 1 row affected (0.03 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | firstdb | | mysql | | orademo | | performance_schema | | test | +--------------------+ 6 rows in set (0.10 sec)
  • 24. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 24 MariaDB : Create DB & User MariaDB [(none)]> create database firstdb; (or create database firstdb default charcter set utf8mb4;) Query OK, 1 row affected (0.03 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | firstdb | | mysql | | orademo | | performance_schema | | test | +--------------------+ 6 rows in set (0.10 sec)
  • 25. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 25 MariaDB : Create Table MariaDB [firstdb]> create table tab_test ( -> tid bigint not null auto_increment, -> tname varchar(100) not null, -> tmeno text not null, -> primary key(tid), -> index ix_tname_tid (tname, tid) -> ) ENGINE=InnoDB; MariaDB [firstdb]> show create table tab_test; ------------+ | Table | Create Table | +----------+----------------------------------------------------------------------------------------------------- | tab_test | CREATE TABLE `tab_test` ( `tid` bigint(20) NOT NULL AUTO_INCREMENT, `tname` varchar(100) NOT NULL, `tmeno` text NOT NULL, PRIMARY KEY (`tid`), KEY `ix_tname_tid` (`tname`,`tid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | +----------+----------------------------------------------------------------------------------------------------- ------------+ 1 row in set (0.11 sec) MariaDB [firstdb]> desc tab_test; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | tid | bigint(20) | NO | PRI | NULL | auto_increment | | tname | varchar(100) | NO | MUL | NULL | | | tmeno | text | NO | | NULL | | +-------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
  • 26. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 26 MariaDB : Modify table (ONLINE/OFFLINE) MariaDB [firstdb]> create table t1 (fd1 int, fd2 enum('red', 'green')); Query OK, 0 rows affected (0.00 sec) MariaDB [firstdb]> alter online table t1 modify fd2 enum('red', 'green', 'blue'); Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [firstdb]> alter online table t1 add fd3 int; ERROR 1915 (HY000): Can't execute the given 'ALTER' command as online  Don't Need : Data Copy to Temp Table – Modify Table Names – Modify Column Names – Modify Number Type Column Length – Modify Table Comment – ENUM Type item add Online Modify Schema : MariaDB 10.0, MySQL 5.6 Over
  • 27. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 27 MariaDB : Modify table (ONLINE/OFFLINE) MariaDB [firstdb]> alter table tab_test add created datetime not null; Query OK, 0 rows affected (0.30 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [firstdb]> alter table tab_test add index ix_created (created); Query OK, 0 rows affected (0.18 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [firstdb]> desc tab_test; +---------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+----------------+ | tid | bigint(20) | NO | PRI | NULL | auto_increment | | tname | varchar(100) | NO | MUL | NULL | | | tmeno | text | NO | | NULL | | | created | datetime | NO | MUL | NULL | | +---------+--------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec)
  • 28. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 28 MariaDB : DML (INSERT) MariaDB [firstdb]> create table tab_test ( -> fd1 int not null, -> fd2 varchar(50), -> primary key(fd1)) engine=innodb; Query OK, 0 rows affected (0.09 sec) MariaDB [firstdb]> insert into tab_test (fd1, fd2) values (1,'Matt'); Query OK, 1 row affected (0.06 sec) MariaDB [firstdb]> insert into tab_test values (2, 'Toto'); Query OK, 1 row affected (0.00 sec) MariaDB [firstdb]> insert into tab_test(fd1, fd2) -> values (3,'Lee') on duplicate key update fd2='Lee'; Query OK, 1 row affected (0.03 sec) MariaDB [firstdb]> insert into tab_test(fd1, fd2) -> values (3, 'SeongUck') on duplicate key update fd2='SeongUck'; Query OK, 2 rows affected (0.04 sec) MariaDB [firstdb]> select * from tab_test; +-----+----------+ | fd1 | fd2 | +-----+----------+ | 1 | Matt | | 2 | Toto | | 3 | SeongUck | +-----+----------+ 3 rows in set (0.00 sec) Option) ON DUPLICATE KEY UPDATE
  • 29. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 29 MariaDB : DML (SELECT) MariaDB [firstdb]> select * from tab_test; +-----+----------+ | fd1 | fd2 | +-----+----------+ | 1 | Matt | | 2 | Toto | | 3 | SeongUck | +-----+----------+ 3 rows in set (0.00 sec) MariaDB [firstdb]> select * from tab_testG; *************************** 1. row *************************** fd1: 1 fd2: Matt *************************** 2. row *************************** fd1: 2 fd2: Toto *************************** 3. row *************************** fd1: 3 fd2: SeongUck 3 rows in set (0.00 sec)
  • 30. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 30 MariaDB : DML (UPDATE) MariaDB [firstdb]> update tab_test set fd2='Brandon' where fd1=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [firstdb]> select * from tab_test where fd1=1; +-----+---------+ | fd1 | fd2 | +-----+---------+ | 1 | Brandon | +-----+---------+ 1 row in set (0.06 sec) MariaDB [firstdb]> select * from tab_test where fd1=1; +-----+---------+ | fd1 | fd2 | +-----+---------+ | 1 | Brandon | +-----+---------+ 1 row in set (0.06 sec) MariaDB [firstdb]> update tab_test set fd2='Brandon'; Query OK, 2 rows affected (0.03 sec) Rows matched: 3 Changed: 2 Warnings: 0 MariaDB [firstdb]> select * from tab_test; +-----+---------+ | fd1 | fd2 | +-----+---------+ | 1 | Brandon | | 2 | Brandon | | 3 | Brandon | +-----+---------+ 3 rows in set (0.01 sec) caution
  • 31. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 31 MariaDB : DML (REPLACE) MariaDB [firstdb]> replace tab_test set fd1=1, fd2='Matt'; Query OK, 2 rows affected (0.00 sec) MariaDB [firstdb]> select * from tab_test where fd1=1; +-----+------+ | fd1 | fd2 | +-----+------+ | 1 | Matt | +-----+------+ 1 row in set (0.00 sec)  REPLACE <-> UPDATE – If, PK or Unique key : Recode Delete & Insert – System Over head – Recommended : INSERT INTO … ON DUPLICATE KEY UP-DATE
  • 32. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 32 MariaDB : DML (DELETE) MariaDB [firstdb]> delete from tab_test where fd1=1; Query OK, 0 rows affected (0.00 sec) MariaDB [firstdb]> select * from tab_test; +-----+---------+ | fd1 | fd2 | +-----+---------+ | 2 | Brandon | | 3 | Brandon | +-----+---------+ 2 rows in set (0.00 sec) MariaDB : AUTO Commit
  • 33. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 33 Reference  Presentation : Ryusuke Kajiyama (MySQL Sales Consulting Manager, JAPAC) – State of the Dolphin – MySQL for Oracle DB  Site : MariaDB Knowledge Base  Book : “Real MariaDB”
  • 34. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 34 Q & A
  • 35. Copyright(c)2014 by ora-sysdba. All Page content is property of dbjongjin.lee Blog : http://ora-sysdba.tistory.com/ 35