
For an instructor lead, in-depth look at learning SQL click below.
Welcome to our beginner’s guide to SQL Server!
Introduction to SQL
Structured Query Language, or SQL, is a standard language for managing and manipulating relational databases. Think of it as a way to communicate with your database, telling it what you want to do, and then receiving a response.
Intro to SQL Server
SQL Server is a relational database management system (RDBMS) developed by Microsoft. It is a software product whose primary function is to store and retrieve data requested by other software applications.
Getting Started
Creating a Database:
In SQL, we create a new database using the CREATE DATABASE statement.
|
1 2 3 |
CREATE DATABASE TestDB; |
This SQL statement creates a new database named ‘TestDB’.
Creating a Table:
Tables are where the data in a database is stored. We can create a new table using the CREATE TABLE statement.
|
1 2 3 4 5 6 7 8 |
CREATE TABLE Employees( ID INT PRIMARY KEY, Name VARCHAR(30), Age INT, Address VARCHAR(50) ); |
This SQL statement creates a new table named ‘Employees’ with four columns: ID, Name, Age, and Address.
Basic SQL Commands
SELECT:
The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.
|
1 2 3 |
SELECT * FROM Employees; |
This SQL statement selects all data from the ‘Employees’ table.
INSERT INTO:
|
1 2 3 4 |
INSERT INTO Employees (ID, Name, Age, Address) VALUES (1, 'John', 30, '123 ABC St'); |
This SQL statement inserts a new row into the ‘Employees’ table.
UPDATE:
|
1 2 3 4 5 |
UPDATE Employees SET Address = '456 DEF St' WHERE ID = 1; |
This SQL statement updates the ‘Address’ column of the ‘Employees’ table for the row where ID equals 1.
DELETE:
|
1 2 3 4 |
DELETE FROM Employees WHERE ID = 1; |
This SQL statement deletes the row from the ‘Employees’ table where ID equals 1.
Conclusion
These are just the basics in SQL Server, and there’s much more to learn! With practice and experience, SQL becomes a powerful tool in managing and working with data. So, good luck on your SQL journey!
