Today, I focused on SQL concepts and explored important commands in MySQL Workbench.
๐ What I Learned
- Table Operations CREATE TABLE IF NOT EXISTS โ Creates a table only if it doesnโt exist. DROP TABLE IF EXISTS โ Removes a table safely (avoids error if it doesnโt exist). SHOW TABLES; โ Lists all tables in the database. DESC table_name; โ Displays table schema (structure).
- Difference Between Commands TRUNCATE โ Removes all rows but keeps the table structure. DROP โ Deletes the entire table structure. DELETE โ Removes specific rows using a condition (WHERE).
- Querying Data SELECT * FROM employees; โ Fetch all rows. SELECT first_name, last_name FROM employees; โ Fetch specific columns. SELECT * FROM employees WHERE emp_id=5; โ Filter rows with condition. SELECT * FROM employees WHERE salary > 50000 AND salary < 60000; โ Using logical operators.
Using LIKE for Pattern Matching
LIKE 'John' โ Exact match.
LIKE 'Jo%' โ Names starting with "Jo".
LIKE '_o%' โ Second character "o".
LIKE 'Raj%Gupta' โ Matches with prefix and suffix.
Uploading imageDate Functions
DAY(hire_date), MONTH(hire_date), YEAR(hire_date) โ Extract date parts.
DAYNAME(hire_date) โ Returns weekday.
FORMAT(hire_date, 'dd') โ Custom date format.
๐ Concepts I Revised
๐น DBMS
Database Management System โ A software to store and manage data (example: MS Access).
๐น RDBMS
Relational DBMS โ Stores data in tables with relationships (example: MySQL, Oracle, SQL Server).
๐น ORDBMS
Object-Relational DBMS โ Supports both relational tables and object-oriented features like inheritance (example: PostgreSQL).
๐น SQL
Structured Query Language โ Standard language for managing and querying databases.
๐น MySQL
An open-source RDBMS widely used in applications (websites, ERP, etc.). Uses SQL syntax.
๐น PostgreSQL (psql)
An advanced ORDBMS, open-source, supports complex queries, JSON, advanced indexing.
๐ How They Connect
SQL โ The language.
MySQL โ A software (RDBMS) that uses SQL.
PostgreSQL (psql) โ A more advanced ORDBMS that also uses SQL (with extra features).
DBMS, RDBMS, ORDBMS โ Categories of database systems where SQL is used.
๐ In simple words:
SQL = Language
MySQL = Tool (RDBMS)
PostgreSQL = Advanced Tool (ORDBMS)
Top comments (0)