|
1 | | -# 🌟 Database Management Systems - BASICS 🌟 |
2 | | - |
3 | | -<img src="https://brainalyst.in/wp-content/uploads/2022/08/Database-Management-System.jpg" /> |
4 | | - |
5 | 1 | ### Introduction 📚 |
6 | 2 | Whether you are just starting with databases or looking to refine your skills, this repository offers comprehensive insights into designing, querying, and managing relational databases. Explore the core concepts through practical examples and detailed explanations tailored for learners and professionals alike. |
7 | 3 |
|
8 | 4 | --- |
9 | 5 |
|
10 | 6 | ### Contents 📋 |
11 | 7 |
|
| 8 | +* *[SQL Commands](sql-commands.md)* |
12 | 9 | 1. **Data Definition Language (DDL)** |
13 | 10 | - CREATE 🛠️ |
14 | 11 | - ALTER ✏️ |
@@ -177,51 +174,3 @@ SAVEPOINT sp1; |
177 | 174 | -- Rollback to the savepoint |
178 | 175 | ROLLBACK TO SAVEPOINT sp1; |
179 | 176 | ``` |
180 | | ---- |
181 | | - |
182 | | -### Examples 📋 |
183 | | - |
184 | | -#### Creating and Managing a Database 🛠️ |
185 | | - |
186 | | -```sql |
187 | | --- Create a new database |
188 | | -CREATE DATABASE company_db; |
189 | | - |
190 | | --- Use the new database |
191 | | -USE company_db; |
192 | | - |
193 | | --- Create an employees table |
194 | | -CREATE TABLE employees ( |
195 | | - id INT PRIMARY KEY, |
196 | | - name VARCHAR(50), |
197 | | - age INT, |
198 | | - department VARCHAR(50) |
199 | | -); |
200 | | - |
201 | | --- Add a new column to the employees table |
202 | | -ALTER TABLE employees ADD salary DECIMAL(10, 2); |
203 | | - |
204 | | --- Insert records into the employees table |
205 | | -INSERT INTO employees (id, name, age, department, salary) VALUES |
206 | | -(1, 'John Doe', 30, 'HR', 60000), |
207 | | -(2, 'Jane Smith', 25, 'Finance', 55000), |
208 | | -(3, 'Mike Brown', 35, 'IT', 70000); |
209 | | - |
210 | | --- Retrieve all employees |
211 | | -SELECT * FROM employees; |
212 | | - |
213 | | --- Update an employee's age |
214 | | -UPDATE employees SET age = 31 WHERE id = 1; |
215 | | - |
216 | | --- Delete specific employees |
217 | | -DELETE FROM employees WHERE age < 30; |
218 | | - |
219 | | --- Truncate the table |
220 | | -TRUNCATE TABLE employees; |
221 | | - |
222 | | --- Drop the table |
223 | | -DROP TABLE employees; |
224 | | - |
225 | | --- Drop the database |
226 | | -DROP DATABASE company_db; |
227 | | -``` |
0 commit comments