SQL Tutorial
Structured Query Language (SQL) is the standard language used to interact with relational
databases.
• Mainly used to manage data. Whether you want to create, delete, update or read data,
SQL provides commands to perform these operations.
• Widely supported across various database systems like MySQL oracle, PostgreSQL, SQL
Server and many others.
• Mainly works with Relational Databases (data is stored in the form of tables).
Writing First SQL Query
Before running SQL queries you need to set up a database server like MySQL, PostgreSQL or
SQLite. Here, we are going to use MySQL server. Follow below steps to set up a basic SQL
Environment:
1. Install MySQL in your system
2. Start MySQL Server
3. Access MySQL Command Line
After your MySQL environment is set up, you can write your SQL program. Below is the example
to display " Hello World" using SQL.
1. Create a database named test_db
CREATE DATABASE test_db;
2. Use the test_db database
USE test_db;
3. Create a table named greetings
CREATE TABLE greetings (
id INT PRIMARY KEY,
message VARCHAR(255)
);
3. Insert the message 'Hello, World!' into the greetings table
INSERT INTO greetings (id,message)
VALUES (1,'Hello, World!');
4. Retrieve the message from the greetings table
SELECT message FROM greetings;
Output: