
For an instructor lead, in-depth look at learning SQL click below.
Welcome to the exciting world of SQL (Structured Query Language)! If you’re new to databases, this guide is for you. Here, we will introduce you to some basic SQL queries. This guide is designed for beginners, so no prior experience with SQL is needed.
What is SQL?
SQL, also known as Structured Query Language, is a conventional computer language for relational database management and data manipulation. SQL is used to modify and access data held in a relational database management system, or for stream analytics in a relational data stream management system.
Basic SQL Commands
Here are the six basic SQL commands that you absolutely must know:
- SELECT: Retrieves data from one or more tables
- INSERT: Inserts new data into a table
- UPDATE: Changes existing data in a table
- DELETE: Removes data from a table
- CREATE: Creates a new table, view, or other object in database
- DROP: Deletes an entire table, view, or other object in the database
1. SELECT
|
1 2 3 |
SELECT * FROM Customers; |
This SQL query will select all columns from the “Customers” table. Here, * represents all the columns of the table.
2. INSERT
|
1 2 3 4 |
INSERT INTO Customers (CustomerName, ContactName, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Norway'); |
Using this query, you’ll insert a new row into the “Customers” table with values ‘Cardinal’, ‘Tom B. Erichsen’, and ‘Norway’.
3. UPDATE
|
1 2 3 4 5 |
UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1; |
This query will update the “ContactName” and “City” of the customer where “CustomerID” is 1.
4. DELETE
|
1 2 3 4 |
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste'; |
This query will delete the customer ‘Alfreds Futterkiste’ from the “Customers” table.
These are simply the basics! SQL is a powerful language offering much more complex operations. As you continue to learn, you’ll uncover more functionalities and applications. Happy coding!
