Free Ebook cover Basic to Advanced Logic Programming Course

Basic to Advanced Logic Programming Course

New course

50 pages

Basic SQL

Capítulo 32

Estimated reading time: 3 minutes

+ Exercise
Audio Icon

Listen in audio

0:00 / 0:00

Structured Query Language (SQL) is a programming language used to manage and manipulate relational databases. SQL allows users to access, modify, view and manipulate their data efficiently and easily. This chapter of our logic programming course will cover the basics of SQL, from creating tables to running complex queries.

Understanding SQL

SQL is a declarative language, which means the user specifies what they want (eg, retrieve data, update data), and the database system figures out how to accomplish the task. In other words, the user doesn't have to specify how to get the data, just what they want to get.

Basic SQL Commands

There are four basic SQL commands that every programmer should know: SELECT, INSERT, UPDATE, and DELETE. These commands allow the user to retrieve, add, modify and delete data in a database.

SELECT

The SELECT command is used to retrieve data from a database. The basic syntax is:

SELECT column_name(s)
FROM table_name;

For example, to select all data from the 'name' column of the 'customers' table, you would use:

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

SELECT name
FROM customers;

INSERT

The INSERT command is used to insert new records into a table. The basic syntax is:

INSERT INTO table_name (column1, column2, column3,...)
VALUES(value1, value2, value3,...);

For example, to insert a new customer into the 'customers' table, you would use:

INSERT INTO customers (name, email)
VALUES('John', 'joao@email.com');

UPDATE

The UPDATE command is used to modify existing records in a table. The basic syntax is:

UPDATE table_name
SET column1 = value1, column2 = value2,...
WHERE condition;

For example, to update a customer's email in the 'customers' table, you would use:

UPDATE customers
SET email = 'new@email.com'
WHERE name = 'John';

DELETE

The DELETE command is used to delete existing records in a table. The basic syntax is:

DELETE FROM table_name
WHERE condition;

For example, to delete a customer in the 'customers' table, you would use:

DELETE FROM customers
WHERE name = 'John';

Conclusion

The basic SQL commands above are just the tip of the iceberg when it comes to working with SQL databases. However, understanding these fundamentals is essential for any programmer. In the next chapter, we'll explore more advanced topics in SQL, including joins, subqueries, and aggregate functions.

We hope that this chapter has provided you with a solid introduction to SQL and that you are eager to learn more about this powerful programming language.

Now answer the exercise about the content:

What are the four basic SQL commands every programmer should know?

You are right! Congratulations, now go to the next page

You missed! Try again.

The four basic SQL commands that every programmer should know are: SELECT, INSERT, UPDATE, and DELETE. These commands allow users to retrieve data, add new records, modify existing records, and delete data from a database as explained in the text.

Next chapter

Advanced SQL

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.