Structured Query Language (SQL)
Overview
- SQL is a language used for interacting with Relational Database Management Systems (RDBMS)
-You can use SQL to get the RDBMS to do things for you
- Create, retrieve, update & delete data
- Create & manage databases
- Design & create database tables
- Perform administration tasks (security, user management, import/export, etc)
- SQL implementations vary between systems
- Not all RDBMS' follow the SQL standard to a 'T'
- The concepts are the same but the implementation may vary
SQL Types
- SQL is actually a hybrid language, it's basically 4 types of languages in one
Data Query Language (DQL)
- Used to query the database for information.
- Get information that is already stored there
Data Definition Language (DDL)
- Used for defining database schemas.
- Defining what kind of schema will be there, column etc.
Data Control Language (DCL)
- Used for controlling access to the data in the database.
- User & permissions management
Data Manipulation Language (DML)
- Used for inserting, updating and deleting data from the databases
Queries
A query is a set of instructions given to the RDBMS (written is SQL) that tell the RDBMS what information you want it to retrieve for you
- TONS of data in a DB
- Often hidden in a complex schema
- Goal is to only get the data you need
For example -
SELECT employee.name, employee.age
FROM employee
WHERE employee.salary > 3000;