Start mysql/maridb

sudo mysql -u root -p

or

sudo mariadb -u root -p

both of them will start maridb because we have made mysql as alias of maridb


Create a database

MariaDB [(none)]> create database Students;

Use the database

MariaDB [(none)]> use Students;

Create a table

MariaDB [Students]> create table information (firstname VARCHAR(20),lastname VARCHAR(20),gender CHAR(1),grade INT(10));

Show the table :

MariaDB [Students]> show tables;
+--------------------+
| Tables_in_Students |
+--------------------+
| information        |
+--------------------+
1 row in set (0.002 sec)

Create another table:

MariaDB [Students]> create table courses
    -> ( courseName   CHAR(20),
    ->   teacher   CHAR(20),
    ->   department CHAR(20));

Entering Values into table

MariaDB [Students]> INSERT INTO courses VALUES ('Probability', 'VB' , 'Maths');

Make sure the order of the values is the same as order as the columns

Insert Data only in specified columns

MariaDB [Students]> INSERT INTO courses
    -> (courseName, teacher)
    -> VALUES ('OOP','Bharti Mam');

show table:

MariaDB [Students]> select * from courses;

Output:

+-------------+------------+------------+
| courseName  | teacher    | department |
+-------------+------------+------------+
| Probability | VB         | Maths      |
| OOP         | Bharti Mam | NULL       |
+-------------+------------+------------+
2 rows in set (0.001 sec)

Exit mariaDB

MariaDB [Students]> exit