MariaDB
is a popular, open source, and the community-based project developed by MySQL developers. It is a relational database management technology which provides the same features as MySQL. It is a new replacement for MySQL.MariaDB
is a modification of MySQL
. MySQL
is linked to the Oracle because the trademark is suggested by Oracle
. Thus, the company decided to continue this trademark. As MySQL
name has come from Monty's first daughter "My
", so, for maintaining the continuity MariaDB
has come from elder daughter "Maria
". XtraDB
or InnoDB
storage engines.CREATE SCHEMA
is a synonym for creating a database.CREATE DATABASE Database_name; ​
DROP DATABASE IF EXISTS db-name;
CREATE DATABASE db-name;
CREATE DATABASE student;
Query OK, 1 row affected (0.01 sec)
CREATE OR REPLACE DATABASE student;
Query OK, 2 rows affected (0.00 sec)
CREATE DATABASE IF NOT EXISTS student;
Query OK, 1 row affected, 1 warning (0.01 sec)
student
' ; database existsSHOW DATABASES;
USE database_name; ​
Example :
USE student;
SELECT COUNT (*) FROM mytable; # selects from student.mytable
USE faculty;
SELECT COUNT (*) FROM mytable; # selects from faculty.mytable
The DATABASE () and SCHEMA () returns the default database.
DROP DATABASE Database_name;
DROP DATABASE student;
Query OK, 0 rows affected (0.39 sec)
DROP DATABASE student; ​
ERROR (1008): can't drop database; database doesn't exists [\]w: show warning enabled
DROP DATABASE IF EXISTS student;
Query OK, 0 rows affected, 1 warning (0.00 sec)
CREATE TABLE table_name (column_name column_type);
CREATE TABLE Students(
student_id INT NOT NULL AUTO_INCREMENT,
student_name VARCHAR(100) NOT NULL,
student_address VARCHAR(40) NOT NULL,
admission_date DATE,
PRIMARY KEY ( student_id ));
Query OK, 0 rows affected (0.312 sec)
SHOW TABLES;
InnoDB/XtraDB
can reach the size up to 64 Terabytes
. Although the person may have a great number of tables per databases and so many numbers of databases per server it is enough. SELECT COUNT(user_id) FROM users WHERE <>;
INSERT INTO tablename (field, field2,...) VALUES (value, value2,...);
INSERT INTO
(column1, column2,... )
VALUES
(expression1, expression2, ... ),
(expression1, expression2, ... ),
...; ​
Or you can use it also with WHERE conditionINSERT INTO table
(column1, column2, ... )
SELECT expression1, expression2, ...
FROM source_table
[WHERE conditions];
INSERT INTO person (first_name, last_name) VALUES ('Mohd', 'Pervez');
INSERT INTO abc VALUES (1,"row 1"), (2, "row 2");
INSERT INTO abc SELECT * FROM person WHERE status= 'c';
TRUNCATE [TABLE] [database_name.]table_name; ​
Difference between DELETE and TRUNCATE statement :
TRUNCATE TABLE javatpoint.Students;
Query OK, 0 rows affected (0.031sec).
SELECT * FROM Students; ​
No record found