0% found this document useful (0 votes)
24 views1 page

SQL Basic Commands

The document provides a series of commands for managing a MariaDB database, including showing existing databases, creating a new database and table, describing the table structure, altering the table to add a new column, inserting records into the table, and deleting a record. It outlines the SQL syntax for each operation with examples. The commands are intended for use in a MariaDB environment.

Uploaded by

rjekm6940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

SQL Basic Commands

The document provides a series of commands for managing a MariaDB database, including showing existing databases, creating a new database and table, describing the table structure, altering the table to add a new column, inserting records into the table, and deleting a record. It outlines the SQL syntax for each operation with examples. The commands are intended for use in a MariaDB environment.

Uploaded by

rjekm6940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

All commands are typed after the

MariaDB [db1]>

1. SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| db1 |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+

2. CREATE database db1;

3. CREATE TABLE employees(


-> employee_id INT,
-> first_name varchar(50),
-> last_name varchar(50),
-> hourly_pay decimal(5, 2),
-> hire_date DATE
-> );

4. DESCRIBE employees;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| employee_id | int(11) | YES | | NULL | |
| first_name | varchar(50) | YES | | NULL | |
| last_name | varchar(50) | YES | | NULL | |
| hourly_pay | decimal(5,2) | YES | | NULL | |
| hire_date | date | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+

5. Inserting a new Column:


ALTER TABLE employees
-> ADD phone_number VARCHAR(15);

6. Inserting records:

INSERT INTO employees (employee_id, first_name, last_name, hourly_pay,


hire_date)
VALUES (1, "PeePee", "PooPoo", 500, "1998-09-04"),
(2, "Saiman", "Says", 700, "2000-08-09"),
(3, "Amit", "Bhadana", 900, "1996-08-03");

7. Deleting a record:

DELETE FROM employees WHERE employee_id=<is NULL|2>; // <yaha pe dono me koi


ek without '< >' >

You might also like