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)