DEV Community

Cover image for Very basic introduction (revision tool) to SQL
Jemima M
Jemima M

Posted on

Very basic introduction (revision tool) to SQL

SQL, or Structured Query Language, is like the language we use to talk to databases. Imagine a database as a well-organised storage space. SQL provides a set of commands that act as a sort of translator, allowing us to ask the database questions, add new stuff, updating existing info, or even remove things. It's a way for us to interact with and manage data in databases, making it a crucial tool in the world of information handling. The cool thing about SQL is that its language is designed to be logical and straightforward, aligning neatly with how we organise and think about data in databases.

In this brief blog, I aim to provide a concise introduction to a few essential elements of SQL: commands, data types, and constraints, along with their significance. This serves as a quick and effective revision, offering a streamlined overview of key concepts of SQL.

SELECT:
This command is used to retrieve data from one or more tables.

INSERT:
Used to insert new records into a table.

UPDATE:
Used to modify existing records in a table.

DELETE:
Used to delete records from a table.

CREATE TABLE:
Used to create a new table.

ALTER TABLE:
Used to modify an existing table(add, modify, or delete columns).

WHERE:
Filters records based on specific conditions and allows you to narrow down your queries to specific criteria.

DROP TABLE:
Used to delete an existing table.

Those are some SQL commands and they provide a powerful set of tools to interact with and manage the data in a relational database.

Data Types

INT:
Integer data type.

VARCHAR(n):
Variable-length character string with a maximum length of 'n'.

CHAR(n):
Fixed-length character string with a length of 'n'.

DATE:
Stores date values.

BOOLEAN:
Represents true or false values.

TEXT:
Used for large blocks of text data.

DECIMAL or NUMERIC:
Holds numbers with fixed precision and scale.

TIME:
Represents a specific time of day.

DATETIME or TIMESTAMP:
Combines date and time values.

Data types define the kind of data that a column or variable can hold. They play a crucial role in ensuring data integrity and precision.

Constraints

PRIMARY KEY:
Uniquely identifies each record in a table.

FOREIGN KEY:
Creates a link between two tables.

UNIQUE:
Ensures that all values in a column are unique.

NOT NULL:
Ensures that a column cannot have a NULL value.

Constraints in SQL are rules or conditions applied to a column or a set of columns in a table. They enforce data integrity and maintain the accuracy and reliability of the data in a relational database.

Mastering these fundamentals lays a solid foundation, paving the way for a deeper exploration into the intricacies of SQL.

Thank you for reading into this brief yet impactful blog—it serves as an effective and concise revision.

In the meantime....

KEEP CODING!!

Top comments (0)