🚀 Day 4: Mastering SQL 🚀

RMAG news

Today’s focus was on mastering the fundamentals of table creation and description in MySQL. Understanding these basics is crucial for efficiently managing and organizing data. Here’s a quick rundown:

📌 Creating Tables in MySQL

The CREATE TABLE statement is used to create a new table in the database.

Syntax:

CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints,

);

Example:

CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
BirthDate DATE,
HireDate DATE,
Salary DECIMAL(10, 2)
);

📌 Describing Tables in MySQL

The DESCRIBE statement provides a detailed structure of the table, including column names, data types, and constraints.

Syntax:

DESCRIBE table_name;

Example:

DESCRIBE Employees;

📌 Common Data Types in MySQL

INT: Integer values.

VARCHAR(size): Variable-length string with a maximum length of size.

DATE: Date values in YYYY-MM-DD format.

DECIMAL(p, s): Fixed-point numbers where p is the precision (total number of digits) and s is the scale (number of digits after the decimal point).

🌟 Key Takeaways:

CREATE TABLE is foundational for database structure.

DESCRIBE helps understand the schema and verify table structures.
Knowing data types ensures the right kind of data storage and efficient querying.

Excited to dive deeper into SQL and explore more advanced concepts in the coming days! Stay tuned for more updates. 🚀

Please follow and like us:
Pin Share